Skip to content

Instantly share code, notes, and snippets.

@m5knt
Last active February 1, 2017 02:58
Show Gist options
  • Save m5knt/dcdfb430924d21d01bdff2dccc7e7110 to your computer and use it in GitHub Desktop.
Save m5knt/dcdfb430924d21d01bdff2dccc7e7110 to your computer and use it in GitHub Desktop.
python3 で csv をダンプ
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import csv
import codecs
sheet = csv.reader(codecs.open('foo.csv', 'r', 'utf-8'))
all = [x for x in sheet]
for x in all:
print(x[1])
# 一行目をキーとする方法
sheet = csv.DictReader(codecs.open('foo.csv', 'r', 'utf-8'))
all = [x for x in sheet]
for x in all:
print(x['dat'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment