or write everything at the end?
Depends on what you wish to write. If the overall content you wish to write is small enough, write the whole thing at once.
actually i would like to add a row in the csv one line at a time
That I wouldn't recommend. Instead of writing it line by line, store it into a string then write the whole string into the file.
ok i'll expalin u my problem. I need to write on a csv some error log that i encounter into my app. I made a comparison between 2 values and if they are mismatching i have to write that line into the csv. Now, or i use the write after each comparison or i store all of them into a list and i write the whole list once.
Do the second one
I would disagree
If you aren't doing weird things that can throw an error, etc before writing into a file. And since you don't normally get errors, doing it line by line as Roy said wouldn't be a bad idea
Обсуждают сегодня