I have two lists - list1 when printed looks like this:
[['KR', 'Alabama', 111], ['KR', 'Alabama', 909], ['KR', 'Alabama', 90], ['KR', 'Alabama', 10], ['KR', 'Arizona', 12], ['KR', 'Arizona', 10], ['KR', 'Arizona', 93], ['KR', 'Arizona', 98],....]
And list2 when printed looks like this:
[11, 110, 108,....]
Now I want to join these two lists and write the result into a csv file so that output looks like this:
KR,Alabama,111,11
KR,Alabama,909,110
KR,Alabama,90,108
KR,Alabama,10,34
KR,Arizona,12,45
So basically the values of list2 becomes the 4th column in csv file. I wrote this code in ipython but it produces output in wrong format and also does not write all the records in the file (last 26 records are not in the file):
final_list = zip(list1,list2)
print final_list
cdc_part1 = open("file1.csv", 'wb')
wr = csv.writer(cdc_part1, dialect='excel')
wr.writerows(final_list)
The output in file looks like:
"['KR', 'Alabama', 111]",11
"['KR', 'Alabama', 909]",110
"['KR', 'Alabama', 90]",108
"['KR', 'Alabama', 10]",34
"['KR', 'Arizona', 12]",45
As you can notice there " and [] around the list1 item and strings in list1 have ' around them. How can I get the correct format of output and why last 26 records are not getting written to file?
NOTE: list1,list2 as well as final_list that I am forming all are of same size (300) but yet in file I see only 274 records
 
     
     
     
    