10-14-2024 12:59 PM
Hi,
I am writing data from multiple sensors with Write Delimited Spreadsheet VI. I know how to create headers for each column of data using an array of Strings sent to a separate instance of Write Delimited Spreadsheet and passing that to the original Write Delimited Spreadsheet, but I want to be able to specify the actual filename automatically. Since the column headers are already passed to the File Path input, I'm not sure how to specify both the Headers and the Filename at the same time. (I'm assuming one would normally create the file name by appending the name as a string to the end of the desired file path then passing the resulting string to the File Path input.)
Thanks.
Solved! Go to Solution.
10-14-2024 01:36 PM
Hi mdc,
@mdc0047 wrote:
(I'm assuming one would normally create the file name by appending the name as a string to the end of the desired file path then passing the resulting string to the File Path input.)
There is a BuildPath function. And there are string functions to create strings as you like, and they can be used to create a filename…
@mdc0047 wrote:
Since the column headers are already passed to the File Path input, I'm not sure how to specify both the Headers and the Filename at the same time.
This doesn't make any sense to me.
You can wire a filepath and array data to the WriteDelimitedSpreadsheet function…
10-14-2024 01:40 PM
Please attach the VI in LV2020 or older version (File->Save for previous)
I recommend trying the CSV Logger from SLL Toolkit
Here is an example from the toolkit
10-14-2024 02:09 PM
The tutorials I have so far found online directed me to create an array of Strings that contains all column headers (I'll be outputting long columns of doubles). This array is sent to a separate Write Delimited Spreadsheet VI. This is then passed to the File Path input of the original Write Delimited Spreadsheet VI, causing the array of Strings to be added to the resulting output file as headers. However, if this File Path input is already occupied by headers, I cannot also add a string constant to specify File Path to this input.
Basically, I understand how to add headers to the data OR specify a file path with a file name, but since both of these operations make use of the File Path input node, I don't know how to do BOTH at the same time.
(for reference, I'm basing this off of the following tutorial at timestamp about 19:30
https://www.youtube.com/watch?v=fIy6XT3CdPQ )
Thanks for your help.
10-14-2024 02:13 PM
Thanks for your help. I am looking for something a little less dependent on user input since I will saving so much data. This VI should now be 2020.
10-14-2024 02:20 PM
You're confused- you do not put the headers in the file path (that makes no sense). If the File Path input has header strings... how does LabVIEW know which file to write to?
The reason you call the function twice is that the first time you write to a file with some strings, the second time you write to the SAME file with data. You have to have "Append" set to True to append the data.
You can prove this to yourself by deleting the second "Write to Spreadsheet" function and opening the file. It'll just have some headers.
10-14-2024 02:23 PM
Just saw you posted your code after I wrote my last post. Wire in your desired filename here:
If you do that, there won't be a popup for the user to select a location.
If you review the Detailed Help for Write to Delimited Spreadsheet, you will see the following:
It's opening a popup for the user to select a path since the "file path" input is blank. I know you think you're wiring in the headers to the file path input, but you're not. You wire those to the "1D Data" input.
10-14-2024 02:31 PM
Thank you! That works perfectly.