import json import pandas as pd import os json_file = 'YoutubeComments.json' # JSON 파일 경로 # 한 줄씩 JSON 객체로 불러오기 with open(json_file, 'r', encoding='utf-8-sig') as f: json_data = [] for line in f: json_data.append(json.loads(line)) # 각 줄을 개별 JSON으로 읽기 # JSON 데이터를 DataFrame으로 변환 df = pd.DataFrame(json_data) # CSV 파일로 저장 csv_file = 'YoutubeComments.csv' # 저장할 CSV 파일 경로 df.to_csv(csv_file, index=False, encoding='utf-8-sig') # JSON 파일 삭제 if os.path.exists(json_file): os.remove(json_file) print(f"{json_file} 파일이 삭제되었습니다.") print(f"CSV 파일이 {csv_file}로 저장되었습니다.")