Created
March 18, 2014 11:42
-
-
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.
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,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.
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
taro,tokyo,man,22 | |
hanako,kyoto,woman,56 | |
satoru,kagoshima,man,18 | |
none,fukuoka,45 |
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
# -*- 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