티스토리 뷰
간단한 내용이지만 막상 하려고 하니 조금 시간이 걸려서 정리해둡니다.
import csv
import json
csvfile = open('file.csv', 'r')
jsonfile = open('file.json', 'w')
fieldnames = ("FirstName","LastName","IDNumber","Message")
reader = csv.DictReader( csvfile, fieldnames)
for row in reader:
json.dump(row, jsonfile)
jsonfile.write('\n')
https://stackoverflow.com/questions/19697846/how-to-convert-csv-file-to-multiline-json
How to convert CSV file to multiline JSON?
Here's my code, really simple stuff... import csv import json csvfile = open('file.csv', 'r') jsonfile = open('file.json', 'w') fieldnames = ("FirstName","LastName","IDNumber","Message") reader ...
stackoverflow.com
'개발 일반' 카테고리의 다른 글
[Python] 리스트가 특정 값을 가지고 있는지 확인하기 (0) | 2020.05.07 |
---|---|
[Python] "killed" 명령어 원인 확인하기 (0) | 2020.04.20 |
[python] urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)> 에러 해결 (0) | 2019.12.06 |
통계 관련 기술면접 대비 (1) | 2019.10.17 |
Hadoop 기술 면접 대비 (1) | 2019.10.08 |
댓글