Skip to content

Instantly share code, notes, and snippets.

@aodag
Created March 18, 2014 11:42
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 aodag/9618456 to your computer and use it in GitHub Desktop.
Save aodag/9618456 to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 8 columns, instead of 7. in line 3.
1,none,none,none,taro,tokyo,man,22
2,none,none,none,hanako,kyoto,woman,56
3,none,none,none,satoru,kagoshima,man,18
4,miyoko,none,none,none,fukuoka,45
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 4 columns, instead of 3. in line 3.
taro,tokyo,man,22
hanako,kyoto,woman,56
satoru,kagoshima,man,18
none,fukuoka,45
# -*- coding:utf-8 -*-
import csv
# CSVデータの読み込み
path = 'list1.csv'
with open(path, 'rb') as csvfile:
reader = csv.reader(csvfile)
lists = [row[4:8] for row in reader if row]
# CSVデータの書き込み
path = 'list2.csv'
with open(path, 'wb') as csvfile:
writer = csv.writer(csvfile)
for row in lists:
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment