LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding column names to data file

Hi,

 

I have a question regarding writing to file. Currently in my program, when I start running it, a dialog box pops up and the user gets to pick/ create a file. My data is written on to a file as columns. I want to add column names to the file. Any suggestions on how to do it? Since the file is created by the user at run time and since the column names have to be added just once at the beginning, I'm not sure how to go about doing this. Any suggestions or pointers?

 

Thanks,

Sukanya

0 Kudos
Message 1 of 10
(9,862 Views)

Sukanya,

 

I guess it depends on what kind of file you are writing.  For instance, if you need to write a 2D array of numbers to a text file (ie, CSV file equivalent of Array to Spreadsheet File.vi):

 

  1. Use the Array to Spreadsheet String.vi to create a comma (or any other delimiter) separated string.
  2. Use string concatination to create a string of column labels separated with the same delimiter.
  3. Concatinate your column lable string with your array string.
  4. Use Write Text File.vi to write to a file.

If you need to write the data as you go, your can either pile it up in memory as you go and then do the procedure above, or you can write it out to the file and then open the file and pre-pend the column headers as described above and the replace the file contents.

 

I know, seems messy.  I agree.  Does this help?

-cb

0 Kudos
Message 2 of 10
(9,853 Views)

Here is a way to write headers once and then append data on the fly:

 

WriteFile.png

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 10
(9,846 Views)

dear sir

i wanted to ask you help. i saw your program bt i am having a big problem

here is my VI. i actually have to do a database where there is the name of the student,

date of equipment of borrowal. time of the equiment when it was borrowed and its date

but when am doing this. each time i always have to create a new file each time.

i cant use the only onw file.:(

and also my 2nd problem is that when the output is being yielded, it is repeatedly

givine me the same output twice, thrice and a lot like in the pic below

 

help please

Download All
0 Kudos
Message 4 of 10
(8,540 Views)

Hi Zahkay,

 

Can you please attach your code to this forum? Instead of just an image. I would like to recreate your issue myself. 

 

I do notice that you are not specifying a file path in your first Open/Create/Replace File function, if you do this, then this should solve your first problem of LabVIEW creating a new file each time.

 

Are you using excel? In order to append the data to the end of a file in excel, you can look at the document below, which shows you how to do this.

 

http://digital.ni.com/public.nsf/allkb/EFCE1C25DCE7483E86256CAF00539451?OpenDocument

 

This document is a good starting place, please let me know if you have any questions.

 

Kevin S
Applications Engineer
National Instruments
0 Kudos
Message 5 of 10
(8,486 Views)

thank you very much sir.

which version of labview are you using. i will upload accordingly to what you can open.

i am using labview 2013. yeah sir it is excel.

0 Kudos
Message 6 of 10
(8,467 Views)

sir there is some icon inside the vi that is not present in my toolkit

 

can u please let me know which toolkit to use

0 Kudos
Message 7 of 10
(8,446 Views)

Hi Zahkay,

 

You can open up context help (Ctrl+H) and hover over the icon in question. It will display the name of the icon. Please let me know what is the exact name of the icon, and I will be able to tell you which toolkit to download.

 

Thank you,

Kevin S
Applications Engineer
National Instruments
0 Kudos
Message 8 of 10
(8,420 Views)

hello sir

Referring to the first example from the link you send me

sir like

excel insert cell

and

excel easy table

0 Kudos
Message 9 of 10
(8,414 Views)

hello sir

Referring to the first example from the link you send me

sir like

excel insert cell

and

excel easy table

0 Kudos
Message 10 of 10
(8,414 Views)