LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert a time column in to a text file

Solved!
Go to solution

hi, help me please. In my program, i am trying to write a data array of 100 samples in to a text file in each iteration because the data is more. One more array is there for time. now how to insert this time column in to a text file.

0 Kudos
Message 1 of 6
(2,290 Views)

If I understood correctly, this might help: https://forums.ni.com/t5/LabVIEW/Append-Column-to-Spreadsheet/td-p/2879296

 

Basically, if you have an existing file and you want to add a new column, you'll need to read the file, modify it, and rewrite the file.


GCentral
0 Kudos
Message 2 of 6
(2,285 Views)

Hi sreevani, if you have some delimited text file, then the values are saved row by row, so to insert a column actually means you have to do 1 insert per row. I think the best way would be to read the data into a 2D array. Then transpose the 2D array and concatenate your new column with the 2D array in the way you want. Then transpose the 2D array again before saving it back to the file.

 

Of course if this is critical data, you should save to a new filename until you know it's working exactly how you want.

0 Kudos
Message 3 of 6
(2,283 Views)

thankq very much for the response!

But i have a 80 channels of 100k sampling rate for 30 seconds data is there. To read that file error message like "memory full" is displaying. so, i thought it is better to write 1k samples for each iteration in to the text file and it is done by "Data file viewer". but the time column is absolute. i want relative time. so, as i know the sampling rate i generate the time array and want to insert in the text file. Is it possible?

0 Kudos
Message 4 of 6
(2,045 Views)
Solution
Accepted by topic author sreevani

Hi Sreevani,

 

As Gregory (and I, previously) said, if you want to do this, you'll need to read the whole file into memory.

 

However, since you now said you have many files, you could instead read them file by file and add the appropriate section of your time array to each one.

This prevents needing to load the entire dataset at the same time and could help you avoid running out of memory.

 

Another option is to use LabVIEW 64-bit for this operation, assuming your computer does have more RAM available. I don't think it's generally a good solution to use 64-bit LabVIEW (because some toolkits are still unavailable, etc) but when you need to do an operation on files that will require lots of memory, it might be a simpler choice.

If you can load one file at a time into memory, you should do that instead, because it will save you time installing 64-bit, if nothing else, and will probably run much faster.


GCentral
Message 5 of 6
(2,028 Views)

THANK YOU  VERY MUCH CBUTCHER.

" you could instead read them file by file and add the appropriate section of your time array to each one"

I GOT IT.

 

0 Kudos
Message 6 of 6
(1,941 Views)