0

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?

2
  • 3
    Welcome to StackOverflow. Please read and follow the posting guidelines in the help documentation. Minimal, complete, verifiable example applies here. We cannot effectively help you until you post your MCVE code and accurately describe the problem. We should be able to paste your posted code into a text file and reproduce the problem you described. Commented Oct 25, 2017 at 23:05
  • please provide the csv file and code Commented Oct 25, 2017 at 23:06

1 Answer 1

1

I found the answer. I had to change the writerows to writerow and change the open file method from 'ab' to 'a'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.