티스토리 뷰
파일 읽기
import jsonlines # !pip install jsonlines 해주기
with jsonlines.open(읽기 파일 경로) as read_file:
for line in read_file.iter():
print(line)
파일 쓰기
import json
with open(쓰기 파일 경로, encoding='utf-8') as write_file:
write_file.write(json.dumps(dicts, ensure_ascii=False) + "\n")
dicts에 한글이 포함된 경우, ensure_ascii=False를 설정해주면 유니코드로 변환해 저장하지 않고 한글 형태 그대로 저장할 수 있다.
참조한 사이트 :)
https://support.unpaywall.org/support/solutions/articles/44001867300-how-do-i-read-jsonl-files-
How do I read JSONL files?
The Simple Query Tool and database snapshot provide results in the JSON Lines text format, or JSONL. Each line of the file is one JSON dictionary representing a single record. Since the uncompressed database snapshot is over 100 GB, this is a...
support.unpaywall.org
https://bramhyun.tistory.com/44
[PYTHON] JSONL(JSON LINES)형식
처음 보는 형식이라 정리해두려고 합니다. 1. 정의 jsonl은 json line의 약어로, JSON Lines 텍스트 형식이라고 한다. 말 그대로, JSON 내부에 한 줄씩 JSON을 저장할 수 있는 구조화된 데이터 형식으로 이
bramhyun.tistory.com
반응형
'Python' 카테고리의 다른 글
| **kwargs (0) | 2022.02.23 |
|---|---|
| Pandas, DataFrame 기록 (0) | 2022.01.24 |
| [Python] 리스트 안의 딕셔너리 중복 제거하기 (0) | 2021.10.01 |
| Numpy axis 이해하기 (0) | 2021.09.05 |
| 두 리스트 빼기 (차집합) (0) | 2021.08.29 |
댓글