From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

how to create a header in csv file

Solved!
Go to solution

I´m still newbie in Labview, I just learnt it this week..

I want to make a data translation for temperature sensor..

I´m having trouble to create a header in csv file,can anybody help me ?

 

I also attach my csv file, what I wanted to make is like this :

dt ( ms ) channel 0 channel 1 channel 2
0,1 1 2 3
0,2 4 5 6
0,3 7 8 9
0,4 10 11 12

 I also want to know how to make the time count from 0 not from the real time..

 

Download All
0 Kudos
Message 1 of 8
(6,172 Views)

Write your header as a 1D array of strings before the loop and then inside the loop write your data in "append" mode.

 

And what's with the juggling of using convert from dynamic data on a DBL to get a DBL (!!!) and then converting it to dynamic data, and then using convert from dynamic data again, to get an array. (!!!!!!!) Just connect the value you are getting directly to the string conversion function. Geez. 

0 Kudos
Message 2 of 8
(6,149 Views)

 

Here you go:

 

If file doesnt exists, create file with header otherwise write data only.

 

 

Header.pngheader_false.png

Message 3 of 8
(6,147 Views)

,I have tried that way,but the result is like this :

 

test1 test2 test3  
05:04:2012   16:39:21 0,152588
05:04:2012   16:39:21 0,274658
05:04:2012   16:39:21 0,244141
05:04:2012   16:39:21 0,221252
05:04:2012   16:39:21 0,189209
05:04:2012   16:39:21 0,218709

 

 is it like that ?

Download All
0 Kudos
Message 4 of 8
(6,137 Views)

You have a different delimiter for the header. It is a tab since it is unwired but your data delimiter is a semicolon. Make them both the same and it should work.

=====================
LabVIEW 2012


0 Kudos
Message 5 of 8
(6,126 Views)

I already solve the problem, It´s quite confusing, I must use ; instead of \t at the delimiter.

I have another question to ask :

- When I start the program,can I make the dt(ms) count from 0 ? What I can do is using the Format/Date time string, I don´t want the time count based on the real time.

 

This is what I made

dt(ms) Ch0
10:04:2012  13:12:06,871 24,139404
10:04:2012   13:12:08,924 23,773193
10:04:2012   13:12:08,925 23,132324
10:04:2012   13:12:08,926 22,918701

 

What I want is like this :

dt(ms) Ch0
0 24,139404
0,01 23,773193
0,02 23,132324
0,03 22,918701

 

 

Thx for the helps..

 

Regards

Citras

 

0 Kudos
Message 6 of 8
(6,080 Views)
Solution
Accepted by Citras

@Citras wrote:

I already solve the problem, It´s quite confusing, I must use ; instead of \t at the delimiter.


What is so confusing about it?  You chose to use the semicolon, so you have to explicitly tell the VI to use that instead of its default of a tab.

 


When I start the program,can I make the dt(ms) count from 0 ? What I can do is using the Format/Date time string, I don´t want the time count based on the real time

You can subtract the current time from the time at the start of the program. Use the Get Date/Time in Seconds function outside the loop to give you the time at the start, and then use it inside to get the current time. Subtract. Be aware that your loop is software-timed, so you're NOT going to get the same delta time.

 

 

Also: do not hard-code paths in the code. What do you think will happen if someone tried to run your VI on an XP machine? It will not work because of the path for the file. Use a control with a default value set for it.

Message 7 of 8
(6,059 Views)

I was working on duplicating the Create a header in csv file  One issue with the false is that the data is not recorded.  You have to actually add one more step or the data for first run will not be added to the file. So I can in this case run a test run and actually in my case  add date to the file to get a file for daily results. 

example of file name changing daily

0 Kudos
Message 8 of 8
(5,535 Views)