07-12-2013 10:16 AM
Hello,
I am trying to use the input value (voltage,current) as the file name in a while loop. the voltage and current are increment in the while loop.
I want to save one file in each iteration and the file name is C:\voltage_current.csv .
Does anyone how to keep updating the file name in a loop?
Thanks,
Tian
Solved! Go to Solution.
07-12-2013 10:29 AM - edited 07-12-2013 10:50 AM
The most straight forward way I can think to do this would be adding the following into the loop: Number to Fractional String to convert these values to strings, and then String Concatenation to create the correct file name. Also concatenate that file name with the path of your save location. Lastly convert String to Path.
Unfortunately my current comptuer doesn't have LabVIEW installed, so I cant create a nice demo. But you should be able to just wire those together without too much confusion. It will look like so:
["C:/path/goes/here/"] -----------------------> [ ]
[voltage] --> [Number to Fractional String] --> [ ] ---> [String to Path] -->
["_"] -------------------------------------> [ String ]
[current] --> [Number to Fractional String] --> [ Concatenation ]
[".csv"] -------------------------------------> [ ]
The only possible issue I could foresee is if you coincidentally come across the same voltage/current.
For example:
Voltages - Currents
1 2
2 2
3 2
4 2
1 2
You could get file names like so:
1_2.csv
2_2.csv
3_2.csv
4_2.csv
1_2.csv **Error. Depending on your settings, this will cause the file to get overwritten,throw an error, or be appended.
Keep this in mind if you won't have exclusively different combinations for every file.
07-12-2013 10:40 AM
MrHappyAsthma has pointed you in the right direction.
If you are starting out with numeric you need to convert them to strings, append them to a base file name and use string to path to use them when writing to a file.
To avoid over writing provious file I would suggest also appending a time stamp converted to a string to your file name.
That way every file will have a unique name.
07-12-2013 02:38 PM
This is exactly what I want.
Thanks!
07-12-2013 02:38 PM
Thanks!