| import pandas as pd | |
| # 入力となるJSONファイル名 | |
| input_json_file = 'dataset.json' | |
| # チャンクサイズ(16分の1に設定) | |
| chunk_size = 1600240008 // 59 | |
| def process_data_chunks(): | |
| # JSONファイルを読み込み、指定した行数ごとに分割する | |
| for chunk in pd.read_json(input_json_file, lines=True, chunksize=chunk_size): | |
| yield chunk | |
| # ジェネレータを使ってチャンクごとにデータを処理する | |
| for chunk_count, data_chunk in enumerate(process_data_chunks(), start=1): | |
| output_file = f'output{chunk_count}.json' | |
| data_chunk.to_json(output_file, orient='records', lines=True) | |