Skip to content

Instantly share code, notes, and snippets.

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