05-06-2010 11:13 AM
Hi there,
the write to spread sheet file VI is inside the for loop. How can I generate a new file and save the data for each loop?
I tried the " append the file (new file, false) option, but it didn't work.
Thanks,
Lei
05-06-2010 12:11 PM
Hi - are you looking to create a new file on every iteration of the loop or create a single file and log the data on every iteration?
If you want to create a new file on every iteration you need to supply a new file name each time.
If you want to add the data to the same file on every iteration simple set "append to file" = TRUE
If this doesn't work post your code and we can take a look
05-06-2010 12:20 PM
To create a new file each iteration of the loop, you must change the file name on each iteration. you can do this by appending the loop iteration number to the end of the file name as shown below:
05-06-2010 12:37 PM
Thanks guys for the reply.
I attach my program here. My application is scanning the spetrometer for several times and save the data separately. so I need a new file for every scan. Another thing is that I am not very sure to put the file I/O inside or outside of the For loops.
Lei
05-06-2010 12:44 PM
You Path variable is always the same. You will only create one file, and it will be overwritten each loop iteration. You will lose all previous data. Two things you could do:
1. Do what I showed you, change the file name (Path) with each loop iteration. Then you will have a bunch of files with the data.
2. Instead of creating a new file each loop, just append the data to the file. Each 2D array of data will be appended to the file. If you do this, it would be nice to have a separator line, maybe a line of all 0's, to separate the data by loop iteration. This is just an option.
05-06-2010 12:51 PM
Hi tbob,
you are absolutely right, when I run the program, there is only one data set in the file.
But how to do your second option? I change the append to file into TRUE, it has the same output with false.......
lei
05-06-2010 12:58 PM
How many loops are being run (# scans)? If it only runs one loop, the outputs will be the same. If it runs multiple loops, the data should append at the end of the file for every loop iteration. Your default value for # scans is 0, which means the loop won't run at all.
05-06-2010 01:02 PM
Thanks tbob,
the # of scan is changable on the front panel,typically I would set it as 10. I run the program but still there is only one set of data in the file
Lei
05-06-2010 01:06 PM
maybe i have to use shift register for the # of scan loop?
05-06-2010 01:09 PM
Use the execution highlite tool (the light bulb). Watch what happens. The Write to Spreadsheet file should execute 10 times, once for each scan loop. Put a probe on the data input to the Write function. See what goes in. This should match what is written. Maybe you have no data after the first scan. Pause the program after each write, open the file and look at the data. Then close the file and continue the program. Let me know what you see.