LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading multiple excel files from a folder in an iterative process

Solved!
Go to solution

My VI collects accelerometer data and saves it as '.xlsx' files. I have updated my code and need to reprocess the data I have collected. My initial step was to use the report generation tool kit to load in each individual file, reprocess the data with the updated code and save in a new location. This is tedious and time consuming when reprocessing as I have over 500 files. 

 

Is it possible to load a folder of excel files into LabVIEW which will iteratively process each file (in a loop) rather than manually entering each file?

Max2796_0-1688378786049.png

Thanks in advance for your help

 

0 Kudos
Message 1 of 8
(1,890 Views)
Solution
Accepted by topic author Max2796

@Max2796 wrote:

Is it possible to load a folder of excel files into LabVIEW which will iteratively process each file (in a loop) rather than manually entering each file?


Of course. Use ListFolder from the File/IO palette to get all files (with specified pattern) and a loop.

FileList.png

0 Kudos
Message 2 of 8
(1,854 Views)

Brilliant thanks! In terms of saving new data should this be perfromed within the loop?

0 Kudos
Message 3 of 8
(1,828 Views)

I've copied what you've suggested which successfully reports the file and folder names, however, when I run the VI the data doesn't match the original file. For all rows I get a matrix of zeros which doesnt match the dimensions of my data and the headings arent the same - see attached...

 

Any suggestions?

 

Max2796_0-1688394684466.png

Max2796_1-1688394719331.png

 

0 Kudos
Message 4 of 8
(1,815 Views)

I managed to solve the previous issue using an alternative method of loading in the data as my data is .xlsx and not .csv

 

However, I'm still having issues saving the data. I've tried having the write to measurment file inside and outside the for loop but still not able to save the data. 

 

For simplicity I've removed my data processing in the attached VI. So for this example I would be saving the same data I've read into a different folder. 

 

Is write to measurement file the best method for saving data? I've found this method clumsy when saving several parameters as it requires alot of effort to incorporate a new variable in the middle of the series. If you can suggest a better method this would be much appreciated.

Download All
0 Kudos
Message 5 of 8
(1,801 Views)

My example was exactly that, an example for proccessing all files from a folder with ReadDelimitedSpreadsheet. But you solved that yourself.

 


@Max2796 wrote:

Is write to measurement file the best method for saving data? I've found this method clumsy when saving several parameters as it requires alot of effort to incorporate a new variable in the middle of the series. If you can suggest a better method this would be much appreciated.


All Express VIs have a bad reputation, except for TimeElapsed. I would recommend avoiding them. Why not use the report generation toolkit for creating the new file? But I can't help with that because we don't use it.

 

An other way to store data in Excel is via Activex calls. Here I add a comment to a cell:

Excel-Comment.png

 

Your original data is just a series of numbers, you don't need Excel for that, csv is enough for that and that makes loading and saving much easier - just a thought.

0 Kudos
Message 6 of 8
(1,758 Views)

@alexderjuengere wrote:

you may take a look at https://forums.ni.com/t5/LabVIEW/Darren-s-Occasional-Nugget-09-26-2022/m-p/4257690


As far as I know the VI fom Darren is only to read data from Excel. I don't know if anyone has already created a variant of it for writing.

0 Kudos
Message 8 of 8
(1,722 Views)