LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic creation of headers in CSV file if there is no headers

Solved!
Go to solution

Hi edmund,

 

when I run your VI and let it create a new file then the header line is written…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 11 of 17
(1,367 Views)

@edmund99 wrote:

Hi all i would like to ask how can i make my programme automatically create headers for my csv file if the file has no headers in it.

 

i have tried to troubleshoot on my own but to no avail.

 

For the "test excel(1).vi" file, the headers will be generated every time i run my vi( repetition of headers)

 

For the"test excel(2).vi"file, the headers must be manually entered into the csv file.

 


To get the "header" information written every time your vi runs keep the code in the case structure but remove the case structure. Based on your picture from your second post this seems to be what you want??? Each time the vi runs on the same file it will insert a new "header" line with "Date","Time", etc.

 

Capture.PNG

 

0 Kudos
Message 12 of 17
(1,359 Views)

@GerdW wrote:

Hi edmund,

 

when I run your VI and let it create a new file then the header line is written…


Hi GerdW hod did you manage to get the headers written? I cannot get it still....

0 Kudos
Message 13 of 17
(1,345 Views)

Hi this is what i want to achieve..... I do not want to have multiple headers . Just one row will do. For now i must manually enter the headers into the CSV file , I want to automate the process and not have multiple row of headers, just one row at the top of the CSV file will do

 

yyxx.JPG

0 Kudos
Message 14 of 17
(1,344 Views)

@GerdW wrote:

Hi edmund,

 

when I run your VI and let it create a new file then the header line is written…


Hi all when i tried running Mr Sarbari's vi first and then letting it create a new notepad text document

i got what i wanted, which was auto generating the headers at the 1st row.  The image i attached bellow are the types of files that  can be created when i run my vi then create a file.Just wondering is there a way to create a csv excel file ? Or i have to manually export data from my text document to my excel csv?

yxyx.jpgxyxy.JPG

0 Kudos
Message 15 of 17
(1,313 Views)

There is no such thing as a "Notepad" text document.  There is no such thing as an "Excel" CSV file.

 

Both are text documents.  Any application can open them assuming it knows what to do with the text data inside.  What you consider is a "Notepad" or "Excel" type of document is probably how the operating system associates particular file extensions with particular applications so it will automatically open in that application when you double click.

 

So a text file with a ".txt" extension will open in Notepad under the typical Windows association.  A text with a ".csv" extension will open automatically in Microsoft Excel, typically.  Excel doesn't make a CSV file particularly special.  It is a completely different file format than a Microsoft Excel ".xls" file or an Excel ".xlsx" file, which are also different from each other.

Message 16 of 17
(1,312 Views)

A CSV is a Comma Separated Values-file. It's a text file with the same format as your posted .txt, so all you need to do is change the extension from .txt to .csv.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 17 of 17
(1,288 Views)