02-13-2020 09:35 PM
Bob gave you the answer.
Write two files. You say "no, it must be one file". Well, when you are done your acquisition, open the header file you created second, and start adding data to it from the data file you wrote first. Then delete the original data file.
02-13-2020 09:47 PM
Thank you again for your time to answer. Yes, that is what I am doing, but sometimes the data file size is big, and labview cannot really open it without an error message. Anyway, it seems there is no alternative to creating 2 files, opening, inserting ,... this is unpractical but it does the job.
There is a plenty of space for experts to implement a new sub vi like "write to spreadsheet but with including header update", without going through the actual method consisting of multiple file manipulations.
What is needed is "insert string into" for an existing string data array (because headers are string, and DBL data have been already converted to string).
02-13-2020 10:24 PM
You have provided lots of reasons why the suggestions that we've made "won't work" for you, but you have not really given us a good idea of (a) the appearance of your data file (without the headers), (b) an example of the kind of modification you would like to make, and some idea of when and how you will know what to insert, and (c) more details on the size of your data file.
Are you writing an Excel file? I believe you mentioned "xlsx", but you show in the very limited picture (which gives us not much idea of what you are doing) what appears to be a "Write Delimited Spreadsheet" function, which writes a text file, not an Excel file, and you name it with the extension ".csv", appropriate for a Comma-Delimited-Values text file. You mention a quantity "50 Mo" -- I'm unfamiliar with this unit, but I assume it is rather large.
We could certainly provide more "appropriate-to-your-problem" help if you did the following:
If, indeed, your files are Delimited Spreadsheet files, and are hundreds of megabytes in size, I would guess to add a few kilobytes (or even a megabyte) of data to the beginning of the file as the program is exiting would delay you maybe a few minutes, at most.
Bob "Still trying to help" Schor
02-13-2020 10:59 PM
You don't need to read the entire file at once!
As I said, you can read the one file line by line as you write it to the other file.
02-14-2020 09:09 AM - edited 02-14-2020 09:10 AM
Frankly it sounds like Bob has the right idea.
02-14-2020 04:40 PM
once again, thank you very much for taking time to answer, now I have fully understood the method and implemented it in my big program. I confirmed it was working for small data acquisition. I am now running an experiment for 4 days, which will generate 50Mega bites of data (50 Mo, for those who wrote that they don't know about Mega octet ... anyway), and I will tell you later if this method was efficient for big size data. Please wait.
The aim of my post was just to alert on the fact that such file manipulation is not very direct, and in a near future, I hope Labview developers to build a new function for adding headers to any text file a priori (but it is already available) but mostly for a posteriori of having writing data in the file, which is a new idea for improving labview without using temporary file as suggested.
What is needed is an "insert text as header" in an already opened text file, before closing it (end of recording).
02-14-2020 04:41 PM
FYI, you can avoid "opening" the files by using a cmd line such as:
copy file1+file2 targetfile
Where:
File1 = header file
File 2 = data file
However, I am not sure how will windows will perform with such large files. I fear it will be very slow.
02-14-2020 10:37 PM
@arienai wrote:
.... and in a near future, I hope Labview developers to build a new function for adding headers to any text file a priori (but it is already available) but mostly for a posteriori of having writing data in the file, which is a new idea for improving labview without using temporary file as suggested.
What is needed is an "insert text as header" in an already opened text file, before closing it (end of recording).
It is not up to LabVIEW developers to create that. It is up to the developers of the operating system to do that. You just can't "insert" stuff at the beginning of the file. It is a limitation of the operating system!