I have two type of csv's having data like:
Format 1 read from csv created from spreadsheet having two coloums.
datas = [[u'Woeoe;"ww@w.com"'], [u'wqqq;"Ww2@2.com"'], [u'Asasasa;"122@22.co.in"']]
format 2 read from the csv created from text editor save as .csv and having data like
fname lname,email@email.com
fname1 lname2 ,email@email1.com
datas = [[u'Vaada sasoe ', u'ssdoe@d.com'], [u'skdod asksd ', u'shashias@ssdsd.com']]
i have read those files with csv reader:
reader = csv.reader(input, quotechar='"', delimiter=',')
datas = []
for line in reader:
datas.append(line)
how do i handle those two different format output of csv reader ? is their any way that i can convert the data while reading in to one simple comma separated format like format2 mention above if i input the any type of csv ? basically i want to data read should be in always in format2.
解决方案
The first file use ";" as delimiter. So, you just have to say it to the reader.
Try to read the first file with csv.reader(input, quotechar='"', delimiter=';')