Skip to content

Instantly share code, notes, and snippets.

@dogrunjp
Created January 31, 2016 18:52
Show Gist options
  • Save dogrunjp/dbeeb3fd3e561ab0b228 to your computer and use it in GitHub Desktop.
Save dogrunjp/dbeeb3fd3e561ab0b228 to your computer and use it in GitHub Desktop.
メモリ上のCSVをリストに変換する方法。ファイルからCSVを読み込んだときのCSVと同様にcsv.rader()すると一文字ごとのリストが返ってしまうので、直接改行コードで区切りリストにする必用がある。urlopen()したcsvでも同様。
with BytesIO() as f:
   ftp.retrbinary('RETR ' + filename, f.write)
   data_list = f.getvalue().decode('utf-8').strip().split("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment