Skip to content

Instantly share code, notes, and snippets.

View brucewlee's full-sized avatar

Bruce W. Lee brucewlee

View GitHub Profile
@brucewlee
brucewlee / csv-to-pd-to-ndjson.py
Last active August 22, 2022 14:03
from csv to Pandas to Newline Delimited JSON
# 참조 https://sooeun67.github.io/data%20science/convert-pandas-to-ndjson/
df = pd.read_csv(f'{target_file}.csv')
df.to_json(f'{target_file}.json', orient="records", lines=True)
# https://sooeunoh.tistory.com/7
with open(os.path.join({FILE_PATH}, {ITEM_FILE}), encoding='utf-8-sig') as f: # 한글 데이터인 경우 encoding 설정
data = ndjson.load(f) # ndjson 으로 읽고
org_data = pd.DataFrame(data)