add row to existing csv file in python -


i want use function add row of information existing csv file.

friend_info tuple including [name, address, phone, dob]

i have code

def add_friend(friend_info, friends_list):     open(friends_list, 'a') fapp:         writer = csv.writer(fapp)         writer.writerow(friend_info) 

for reason code adding last line of csv (i want start on new line)

i don't think csv writer object smart enough know it's appending onto existing csv data. you're giving file object , telling put new csv data file, starts writing can. start new row, need read existing data in first, append new row(s), write out.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -