Reputation: 896
I want to append a list into a csv file in python
listoflist = [rhyme_cnt[row],gaali_cnt,diversity[row]]
This list contains three variables and the code I'm using to write this is
with open('C:/Users/Samarth/Desktop/Minor/songlyrics/final.csv',"ab") as output:
writer = csv.writer(output,lineterminator = '\n')
writer.writerows(listoflist)
writer.writerows([])
But I'm getting the following error
_csv.Error: iterable expected, not int
What am I doing wrong?
Upvotes: 0
Views: 1570
Reputation: 896
I found the answer. I had to change the writerows to writerow and change the open file method from 'ab' to 'a'
Upvotes: 1