O
O
Ocean_772017-01-03 20:17:38
Python
Ocean_77, 2017-01-03 20:17:38

Questions about writing to csv file?

I connected the csv library, I'm trying to write data from the dictionary to a csv file.
Here is the function:

def write_csv(data):
    with open('weblancer.csv', 'a') as f:
        writer = csv.writer(f)

        writer.writerow( (data['title'],
                                   data['price'],
                                   data['answ'],
                                   data['link']) )

But at the output I get data in this format. It seems to me that there should not be empty entries in the csv file through each line.
c831b81e1e7749b8b99f71daefe10508.PNG
Can anyone suggest what's wrong here?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WalletDat, 2017-01-03
@Ocean_77

writer = csv.writer(f, lineterminator='\n')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question