From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save strings and time stramps to file

Solved!
Go to solution

Hi guys,

I have a VI in which I have made a log file containing names and time stramps I would like to save those into a file an excel file would be good having to columns but I face a problem of how to insert the strings into the "write to measurement file " how can I deal with it please help me thank you

0 Kudos
Message 1 of 6
(3,051 Views)

Do you want an Excel file, or is a CSV file sufficient?

 

To create a CSV file, use the Write Delimited Spreadsheet function. This is available at the top level of File I/O on newer versions of LabVIEW (at least since 2016, I think also 2015. For previous versions, it has a different name but there is a similar function).

 

The default delimiter is 'Tab', so you should wire a string constant value of ',' instead for CSV. For a log file, it's likely you want to set 'Append?' to true (the default is false). You can wire 1D or 2D arrays of strings straight into this function and it will write them to a file for you. You have to pass it a path - you can't give it a file reference, so if you need to write very quickly, you should do the formatting yourself and use the Write Text File node instead.

 

If you want a true Excel file (rather than just a file that opens in Excel) you need to use either ActiveX or the Report Generation Toolkit. ActiveX would be much more complicated - I wouldn't suggest it to you.


GCentral
0 Kudos
Message 2 of 6
(3,034 Views)

Hi, thanks for your reply

but I have a question  can I write the current time next to the string ?

because this is what I'm after

or do I need to stream the data in one line after converting the time stramp to string and then use the delimiter and then combine them both ???

 

0 Kudos
Message 3 of 6
(3,028 Views)

Use a FOR loop to convert your time stamp into a string.  You can just add a comma (or tab) and your string to at the same time.  You can then use Write To Text File to write your data.  Just be sure you open you file before your main loop starts and close it when you are done.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 6
(3,019 Views)
Solution
Accepted by topic author AnouarDTH

You can convert a timestamp to a string directly if you want, but the timestamp probably wouldn't be very useful. I suspect that what you want is either the Format to String node with a time format, or some use of the Get Date/Time String. I always prefer the Format to String option.

 

Assuming you just want a message and a time string, something like this should work out fine:

 

basicLogger.png


GCentral
0 Kudos
Message 5 of 6
(3,013 Views)

thank you so much guys for your help

0 Kudos
Message 6 of 6
(3,003 Views)