取消
显示结果 
搜索替代 
您的意思是: 

file I/O write to spreadsheet file vi

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

 

0 项奖励
1 条消息(共 16 条)
5,250 次查看

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

 

David
www.controlsoftwaresolutions.com
0 项奖励
2 条消息(共 16 条)
5,233 次查看

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:

 

UniqueFilename.png

 

- tbob

Inventor of the WORM Global
3 条消息(共 16 条)
5,229 次查看

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

 

 

0 项奖励
4 条消息(共 16 条)
5,222 次查看

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.

 

- tbob

Inventor of the WORM Global
0 项奖励
5 条消息(共 16 条)
5,218 次查看

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

 

0 项奖励
6 条消息(共 16 条)
5,214 次查看

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.

 

- tbob

Inventor of the WORM Global
0 项奖励
7 条消息(共 16 条)
5,210 次查看

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

0 项奖励
8 条消息(共 16 条)
5,205 次查看

maybe i have to use shift register for the # of scan loop?

 

0 项奖励
9 条消息(共 16 条)
5,195 次查看

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.

 

 

- tbob

Inventor of the WORM Global
0 项奖励
10 条消息(共 16 条)
5,188 次查看