|
import pandas as pd |
|
import json |
|
import os |
|
from datasets import Dataset, DatasetDict |
|
|
|
|
|
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) |
|
|
|
|
|
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] |
|
|
|
|
|
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] |
|
|
|
|
|
def consolidate_data(): |
|
csv_data = read_csv('nvidia_gpus.csv') |
|
json_data = read_json('nvidia_gpus.json') |
|
ndjson_data = read_ndjson('nvidia_gpus.ndjson') |
|
|
|
|
|
combined_data = pd.concat([csv_data, pd.DataFrame(json_data), pd.DataFrame(ndjson_data)], ignore_index=True) |
|
return combined_data |
|
|
|
|
|
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() |
|
|