LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to append new data into older csv file.

Hello all,

 

I need small help. Please help me.

 

How to append new data into older csv file with File I/O functions.

 

As per below image,

  1. First time I got 3 signals data (Signal-1 to Signal-3) & I stored into *.csv file.
  2. Next time I got 3 signals data(Signal-4 to Signal-6). So, I want to add these signals data to same csv file.
  3. Next time I got other 3 signals data(Signal-7 to Signal-9). So, here again I want to save these signals data to same file.

 

This signals data depends on user request (Signal count is not fixed).

 

Please give me any idea about this.

 

 Image_CSV.png

Munna
0 Kudos
Message 1 of 12
(5,851 Views)

As far I know you cannot append data to the columns unless you read the complete data and append it in LabVIEW and write everything again.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 2 of 12
(5,835 Views)

I thought of reading same file again line by line & adding new data to each line & writing into same file.

But,sometimes offset length is missing to inset new data into old positions. I’m not getting properly.

 

Munna
0 Kudos
Message 3 of 12
(5,826 Views)

If you have the data column wise then just read the data and build it along with the new data (This will be a problem when the file size increases) and write it again. This case you don't have to set the file size since you are re-writing the whole data.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 12
(5,814 Views)

I have comma delimited values.

Here, the problem is, I want to do read & write (old+ new data) into same file.

Suppose, reading 100 lines, replace those 100 with new data & so on.

Munna
0 Kudos
Message 5 of 12
(5,805 Views)
In order to append columns, you need to read in the entire file. Once you have a 2D array with the Read From Spreadsheet File, a simple array manipulation will get your extra columns and then you just write the file back with the same name.
0 Kudos
Message 6 of 12
(5,794 Views)

Dear Dennis_Knustson,

 

Thanks for your reply.

Actually I have large set of data file (file size is huge). So, I’m unable to read entire file at once ( because of memory issues).

Munna
0 Kudos
Message 7 of 12
(5,785 Views)
Then you should rethink the file storage scheme that you are using. Look at the tdms functions.
0 Kudos
Message 8 of 12
(5,782 Views)

Dear Dennis_Knustson,

 

I thought of changing csv to tdms.

But, here also I’m facing other issue.

Sometimes, I need to write string data between some signals (like, Signal data + some conditions information etc.).

 

Now, I’m planning to use report generation toolkit. But execution time will increase.

Is there is any other ways?

Munna
0 Kudos
Message 9 of 12
(5,769 Views)

If the data size is large I would reommend you to go for *.bin files and then convert it to Excel when it is needed. Binary files can hold the different data types as you wish.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 10 of 12
(5,759 Views)