Created
December 3, 2013 12:42
-
-
Save squarednob/7768558 to your computer and use it in GitHub Desktop.
pythonで日本語csvを読み込む問題。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 日本語のcsvファイルを読み込むには、unicodecsvを使う。 | |
#これはcsvを読み込むときにutf-8化した後、出力でunicode化してくれるもの。 | |
#目的のcsvをメモ等などで、utf-8で保存した後、以下で読み込む。 | |
import unicodecsv | |
f = open("utf30.csv","rb") | |
r = unicodecsv.reader(f, encoding='utf-8') | |
row = r.next() #r.next()だけで、rowのインデックスにすべて入る。forループはいらない! | |
print row[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment