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: 

Reading excel files in real time

Hello,

 

I would like to have a labVIEW program which permits to read several excel files, and collect all data in a single excel file.

I know that it is possible to write a program which can read multiple files.

 

But I would like to know that if its possible to read files in a real time:

for ex. each time there is a new excel file to read, the LabVIEW program read it automatically and add its data to the final file?

 

Thank you and bests regards

0 Kudos
Message 1 of 3
(2,724 Views)

You should be a little careful about using the phrase 'real time' around here as that tends to mean deterministic timing with bounded jitter whereas it sounds like your application isn't 'time critical' and more that it should run as the files are generated which is fine and can be done in Windows.

 

There are a couple of ways to do this:

1) Periodically get the list of files in the directory you're monitoring and open/process the new files.

2) Use the .NET FileWatcher component which I think will generate an event you can listen to when files are changed by the operating system.

 

You may have to be a little careful about trying to open the file while it is open in an another program (e.g. Excel).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 3
(2,707 Views)

As Sam notes, it is certainly possible to merge Excel Files (I've done it, myself).  An oft-repeated Best Practice for Program Development, which I didn't understand nor start following until quite recently, is "Write the Documentation First".  In this case, you want to think carefully (and specify in a Document, which tends to "clarify your thinking") a number of issues:

  1. Where will you look for the Excel Files to be merged?  [Hint -- it's much easier if they are all in the same Folder).
  2. Where will you save the Merged File?  Will it be in the same Folder as the Source Files?
  3. How will the Merged File be named?  This can have an interaction effect with the previous points.
  4. What is the structure of the Source, and of the Merged, File?  Is it "obvious" how the Merge is to take place?
  5. Related to #4, are there Headers?  Multiple WorkSheets?
  6. How do you know when it is time to Merge?  Are you checking for new files periodically?  How often?

In some ways, these "structure" questions are trickier to design and thornier to deal with than simply reading data from two Excel Files and writing the data to a third (which I'm calling a Merge).  Note that I'm assuming that you are really dealing with Excel files (.xls, .xlsx), for which I recommend using the Report Generation Toolkit.  If you are speaking about Comma-Separated Variable (.csv) files that LabVIEW calls "Spreadsheets", the above questions are still mostly relevant, but your approach will be a little different.

 

Write yourself a Document, show it to us, and if you have ideas on how to do this, give it a try and show us your code -- we'll try to provide assistance if you "get stuck".

 

Bob Schor

0 Kudos
Message 3 of 3
(2,641 Views)