Quantcast
Channel: Active questions tagged row - Stack Overflow
Viewing all articles
Browse latest Browse all 446

Not able to add the list into new row of CSV file?

$
0
0
List = ['Mean', mean]List2 = ["Variance", variance]List3 = ["SD", std]rows = zip(List, List2, List3)from csv import writerwith open(r'E:\chrome dlds\null - Sheet1.csv', "a", newline = '') as f:    writer = writer(f)    for row in rows:        writer.writerow(row)with open(r'E:\chrome dlds\null - Sheet1.csv', mode ='r') as file:    csvFile = csv.reader(file)    for lines in csvFile:            print(lines)

code snippet

I tried to add lists (List,List1,List2) into CSV file as a new row and expected output to read the lists as new rows.

I am new to CSV module so When using writer function, The output is adding List into last column of the CSV file. I want the list to append as a new row into csv file. Any suggestions?


Viewing all articles
Browse latest Browse all 446

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>