02-18-2019 01:08 PM
Howdy all!
I'm in need of some help regarding the best practice to initialize a new empty 2D array for a shift register inside a while loop.
I'm trying to record data from 2 inputs (I've replaced these with RNGs for the sake of simplicity) along with an elapsed time. The data is then recorded and saved to csv after a button is pressed to begin a new trial. The problem I'm running into is that if I don't empty out the array, I just end up recording all the previous trials (obviously this would defeat the whole purpose of dynamically naming the csv files if the last one will just contain all of the data from all the trials). What are some good ways of solving this?
Thanks in advance folks!
02-18-2019 01:18 PM
Wire the array across the case structure and output an empty array when a new trial starts.
02-18-2019 01:30 PM - edited 02-18-2019 01:39 PM
Some more generic comments to your coding style:
02-18-2019 04:09 PM
Hi Altenbach,
Thank you for your help, particularly with the format string trick which has made my life much easier, esp. since I'm new to labview
One last question: Is there a method to get headers into the csv?
Thanks in advance!
02-18-2019 07:45 PM
Yes, of course. Write a 1D arrays of header strings first, then append your data.
02-19-2019 11:01 AM - edited 02-19-2019 11:06 AM
@altenbach wrote:
- You can add all strings to the format code to generate the file name. No need for all that string gymnastics. (Format would be "Trial%03.0f.csv")
Since its an integer, more correct would be "Trial%03d.csv", of course. The result would be the same.