File size: 1,588 Bytes
0bfbee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pandas as pd
import json
import os
from datasets import Dataset, DatasetDict

# Function to read CSV file
def read_csv(file_path):
    if not os.path.exists(file_path):
        raise FileNotFoundError(f"The file {file_path} does not exist.")
    return pd.read_csv(file_path)

# Function to read JSON file
def read_json(file_path):
    if not os.path.exists(file_path):
        raise FileNotFoundError(f"The file {file_path} does not exist.")
    with open(file_path, 'r') as file:
        return [json.loads(line) for line in file]

# Function to read NDJSON file
def read_ndjson(file_path):
    if not os.path.exists(file_path):
        raise FileNotFoundError(f"The file {file_path} does not exist.")
    with open(file_path, 'r') as file:
        return [json.loads(line) for line in file]

# Consolidate data from different formats
def consolidate_data():
    csv_data = read_csv('nvidia_gpus.csv')
    json_data = read_json('nvidia_gpus.json')
    ndjson_data = read_ndjson('nvidia_gpus.ndjson')

    # Combine all data into a single DataFrame
    combined_data = pd.concat([csv_data, pd.DataFrame(json_data), pd.DataFrame(ndjson_data)], ignore_index=True)
    return combined_data

# Generate summary report
def generate_summary():
    output_file = 'nvidia_gpu_summary_report.csv'
    data = consolidate_data()
    summary = data.describe(include='all')
    summary.to_csv(output_file, index=False)
    print(f"Summary report generated: {output_file}")
    print("Summary report generated: nvidia_gpu_summary_report.csv")

if __name__ == "__main__":
    generate_summary()