Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created March 6, 2020 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/baf7e7e291e42e67a76061f9d3a04ff4 to your computer and use it in GitHub Desktop.
Save ochilab/baf7e7e291e42e67a76061f9d3a04ff4 to your computer and use it in GitHub Desktop.
Python: CSVデータのファイル書き読み処理
import csv
#読み込み
with open('sample.csv') as f:
#リストとして読み込み
csvdata = csv.reader(f, delimiter=',') #delimterの指定はなくてもよい
for row in csvdata:
print(row)
import csv
data = [111,222,333]
with open('sample.csv', 'w',newline='') as f:
writer = csv.writer(f)
writer.writerow(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment