0

How can I extract 2 columns in two python lists out of csv file. I tried everything but I always get errors. I just succeed making rows :

import csv 
with open('test-data.csv', newline='') as csvfile:
    spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
    for row in spamreader:
        print(' '.join(row))
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
L K
  • 1
  • This is simply the sample code of the CSV manual? – Willem Van Onsem Apr 07 '18 at 14:37
  • I took the code from here : https://docs.python.org/3.1/library/csv.html – L K Apr 07 '18 at 15:06
  • I get this type of results : [974] ['Stoob', '59'] [975] ['Hochfilzen', '59'] [976] ['Henndorf', '59'] [977] ['Pischeldorf', '59'] [978] ['Vitis', '59'] I wish i can extract the name of the town for example in a python list [Henndorf, Pischeldorf, Vitis...]... and another list with [59, 59, 58,...] etc... i have more than 1000 datas – L K Apr 07 '18 at 15:07

0 Answers0