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: 

Recording data into excel file in back to back rows

Hi,
I am measuring some physical quantities and recording them into an Excel file with their correspinding date and time using write to spreadsheet.vi day by day and then saving the average for each day into another excel file month by month. now I encounter three problems: first, it saves the data into the odd or even rows of the Excel file, while I want them to be in all rows back to back ; second, when saving the average of each day into another Excel file, I want to have only and only one row for each day while in my program, if I stop the program during the day, it will create another row for that day and does not update the existing row for that day. third, in the monthy Excel file, in the first cell it displays the date and then it displays the average value for that date into third cell. in other words, it displays nothing in the second cell but I want the average value to be in the second cell.

I would be very gratefule if you can please help me to solve my problems<I have attached my program with the Excel files>

Looking Forward to Recieving from You
0 Kudos
Message 1 of 2
(2,143 Views)

As has been mentioned to you several times, you do not have Excel files. You have TEXT files, so please stop calling them Excel files. The method for handling Excel files is completely different from the method for handling TEXT files. People may start thinking you want to use Excel files and start giving you suggestions that don't help you.

 

The first issue you are having with the extra rows is due to the Write to Spreadsheet File VI. It adds an extra line due to the Array to Spreadsheet String function that it uses internally. To get around this you would need to basicall make your own version of the Write to Spreadsheet File that removes the extra line before writing it to file. This is easier than it soundsas you can simply copy the code it has and just add a Match Pattern right after the Array to Spreadsheet String to look for the newline at the end of the string and take the stuff before it.

 

As for the second issue: since you are dealing with TEXT files you have to look at this as if the file I/O were a firehose. The only way to go back into the flow is to move the file pointer. You have to do this yourself - the function will not do that for you. 

0 Kudos
Message 2 of 2
(2,117 Views)