Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 appending to the same csv file
#1
Hi all,
inside of one of my for loops I am keeping four parameters that I want to store into four columns of a csv file

 
# part of an omitted for loop
print('to be saved to the csv, id:',id,' recordNumber: ',recordNumber, 'start_time :',start_time, 'end_time :', end_time )
print('appending to file ', savepath)
during run time what one sees in console is:

to be saved to the csv, id : [3.474377447e+09]  recordNumber:  9975 start_time : 1547445492512.0 end_time : 1547445552407.0
appending to file  69_58_68_93_31_0.csv
How I can append those values to a csv file within the for loop. The filename of course is always the same and only the new calculated four variables need to be added/appended.

Regards
Alex
Quote
#2
If you open the file with the mode of "a" it will append to the end of the file. See:
File Input and Output for Python 3.7.4
Quote
#3
thanks! I will use that.
Anything special for writing a csv file or I just setup the extension when setting the file name.

Thanks again
Alex
Quote
#4
Nothing special. Basically a csv file is a text file with data fields separated by commas and records separated by end of line.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Appending data into a file in tab delimited format metro17 1 211 Aug-06-2019, 07:34 AM
Last Post: fishhook
  appending json file Buddy 5 5,652 Oct-26-2017, 04:37 AM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)