티스토리 뷰
CSV 파일 문법
1. csv파일은 column을 comma로 분리한다.
따라서 데이터 안에 comma가 들어간다면 ""로 묶어주는 과정이 필요하다.
2. 배열 처리하기
"raw_text","aspectTerms"
"I charge it at night and skip taking the cord with me because of the good battery life .","[{'term':'cord', 'polarity':'negative'}]"
이러한 데이터가 있을 때, 처리를 위해서
3. 따옴표 처리하기
작은 따옴표는 괜찮지만 큰 따옴표 "는 ""로 처리해줘야 한다.
파이썬 문법
1. 대괄호 작성: f-string 작성 시
두번 써줘야 한다. {{}}
sentence = f'"{line_1}","[{{\'term\':\'{line_2}\', \'polarity\':\'{line_3}\'}}]"\n'
# "The rude","[{'term':'cab ride', 'polarity':'positive'}, {'term':'driver', 'polarity':'negative'}]"
2. 따옴표 작성: f-string에서
""로 묶었다면, ''는 자유롭게 사용 가능하고 반대로
''로 묶었다면, ""는 자유롭게 사용 가능 하다.
''로 묶었는데 ''를 쓰고 싶다면 backslash 써줘야 한다.