LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Data from Dynamic File Path

I am using an instrument to continuously monitors a process. Each measurement cycle saves a .csv file to a subdirectory within the experiment folder. I am not sure how to access each subdirectory and read the .csv file (all with the filename "integration.csv") as it is being generated by the instrument. Is this possible? I have attached an image of an example file structure and data that is generated from the instrument. 

 

 

 

 

LeCroyJenkins_0-1679410708088.png

LeCroyJenkins_1-1679410754721.png

 

0 Kudos
Message 1 of 6
(1,006 Views)

Are the subfolders unique?

Also do you want know when the file gets saved automatically?

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 6
(1,002 Views)

Hi,

 

You should learn about the following functions:

 - "List Folder" to list files and folders contained in a root folder;

 - "Build Path" to construct a path;

 - "Read Delimited Spreadsheet.vi" to read a csv file.

Read Data from Multiple CSV Files.png

 

Regards.

Message 3 of 6
(996 Views)

Thank you, Raphschru. This works perfect for when all of the folders already exist and a script is run. How would you get the VI to wait on a folder to be created by the instrument before it read the .csv file? For example, I plan to start the experiment and VI at the same time. The instrument will create a new folder every 1-2 min, which I would like read as a spreadsheet. 

 
0 Kudos
Message 4 of 6
(970 Views)

Yes, all of the subfolders are unique, starting from 0000 and increase by 1 integer for each data point (0001, 0002, etc.).

 

It seems like the most straight forward way to do this isfor the program to look for an every increasing folder number and only proceeding if the folder exist. What is the easiest way to implement this? Through a flat sequence? 

 

Thanks for your feedback. 

0 Kudos
Message 5 of 6
(967 Views)

Since all of the folders (and files) are unique (despite having the same or very similar names), the following seems (to me) the logical way to do things:

 

     Use "List Folders" on the folder holding all the sub-Folders.  Parse the name(s) of the Folders to get the one with the highest numerical value.  Now "List Folders" on that "highest" folder.  If it doesn't have any files, wait 2 minutes and try again. 

 

     Now the only thing you need to think about is the relative timing of folder and file-content creation.  Suppose there's a file in the folder -- is it the "latest one", or could it be "left over from yesterday"?  You could simply use the File/Directory Info and get the Last Mod data for the file and compare it with the current time to see how long ago it was written.

 

Bob Schor

Message 6 of 6
(947 Views)