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: 

insert a line into the beginning of a file without overwriting data

I would like to dynamically alter/add new headers to a csv file as needed. The code I have below overwrites the previously written data an amount equal to each new header added each time I call the vi below. Any suggestions on how to do this without reading in the file each time? I want to avoid the processing time of reading in the file between processing new data.

Thanks!

 

 

insert headers2.pnginsert headers.png

0 Kudos
Message 1 of 6
(3,027 Views)

The simple answer is No.

You need to read the entire file to pre-pend that line.

 

If you were actually working with true Excel files, you can.

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

Thanks! That's what I thought.

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

If you're gonna change the file several time during a run you can ofc. keep the data/file in memory and modify that instead.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 6
(2,985 Views)

The problem with that is for days of testing you might loose data if something goes wrong.

0 Kudos
Message 5 of 6
(2,965 Views)

Yes, but you can still write everytime, you dont need to read the file back. 🙂

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(2,956 Views)