CSV
str.split() , str.split() . CSV .
http://en.wikipedia.org/wiki/Comma-separated_values
:
1997,Ford,E350,"Super, luxurious truck"
str.split(), 5 :
('1997', 'Ford', 'E350', '"Super', ' luxurious truck"')
, , , 4 :
('1997', 'Ford', 'E350', 'Super, luxurious truck')
, , , "\ r\n" "\n" . :
1997,Ford,E350,"Super
luxurious truck"
1997,Ford,E250,"Ok? Truck"
, :
file = open('filename.csv', 'r')
for line in file:
# problem here, "line" may contain partial data
, , CSV , , , .
1997,Ford,E350,"Super ""luxurious"" truck"
('1997', 'Ford', 'E350', 'Super "luxurious" truck')
, :
- .
- , , " "
- " " , , .
- " " , . ( , "", "", ", " )
- " " , , .
- , .
- , , , .
, , # CSV. , , . # CSV .
, CSV (, 10 100 . ), . list , ( ). , , reset 0, .
, header = ['Column1', 'Column2'] , , :
record[header[column_index]] += character