본문 바로가기
개발/Python

파이썬 python CSV 파일 저장 불러오기 Read, Write 간단 구현

by SPNK 2023. 1. 30.
반응형
  • CSV 저장하기
import csv

rows = [["Name", "Age", "City"],
        ["John", 30, "New York"],
        ["Jane", 25, "London"],
        ["Jim", 35, "Paris"]]

with open("people.csv", "w", newline="") as file:
    writer = csv.writer(file)
    
    writer.writerows(rows)

 

  • CSV 불러오기
import csv

with open("people.csv", "r") as file:
    reader = csv.reader(file)
    
    for row in reader:
        print(row)
반응형

댓글