Writing an Updating csv file with specific structure

Im doing some tests with spectrometer and want to create an updating csv file containing the results in python. im using pandas and the loop is working great, i was able to creat an updating file but im pretty new to python, and getting hard time creating this specific structure:

the first column will be the date and the local time with an empty cell in the first value. the first row ( starting from the second cell) will be a constant vector. ==> only first row. the second row and all others ( the first value will start from the second cell - first containing the date ) will be variable.

I need help defining this structure and conditions

The result of the code should shown in ecxel as the example picture (in the example there is only time, but i do need times and dates).

Thanks a lot !

Image for reference:


Please show us what you’ve done/tried!

    time_string=time.strftime("%m/%d/%Y, %H:%M:%S", time_tuple)
    fields=['wave length','intensity']
    with open(name, 'a') as f:

data is a  1000x2 , the 2 columns are wave length and transmission

Hey bud , any suggestions? For getting the structure I mentioned?

what went wrong with this code you tried?

Hey Timo im trying to create a specific csv structure as in the picture , right now i’m trying to do so in 2 different scripts , as one creating the date column and wavelengths only ,that every wavelength will be in a separate column.
The other script adds the intensity of the wave to every wavelength column, to the same csv file with the date at first.

data containing the wave lengths and intensity in 2 different columns: data[:, 0] for wavelengths , and data[:, 1] for intensity

right now in the first script (that creates the wavelengths) , i’m getting only a shortcut string of the wavelength in the same tab, can’t understand why

Do you have any suggestions for solving this problem or trying a different method ? .

adding pictures of the 2 scripts and the csv file for the wavelengths.

Thanks alot for helping budd

cheers yuval

script2 => date&time and intensity

now = datetime.now()
time_string = now.strftime("%d/%m/%Y %H:%M:%S")
newData = [time_string, data[:, 1]]
with open(name, 'a') as f:
      write = csv.writer(f)

csv file created from script1

script1 => wavelengths columns and ‘date’ title

for name in names:
    fields = ['date', data[:, 0]]
    with open(name, 'a') as f:
          write = csv.writer(f, delimiter=',')