LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract text file from a folder and read the content

Hi

I have "n" no.of text files saved in a folder with automatically generated naming convention which include DD/MM/YYYY and also some measurement output value.


Eg: 1) Die_1_DUT_outputvalue_DD_MM_YYYY.txt
    2) Die_1_DUT_outputvalue_DD_MM_YYYY_ABC.txt

In the above files part of the 2nd file naming convention same as the first file (i.e. Die_1_DUT and DD_MM_YYYY) whereas outputvalue is different and an additional string named ABC is appended.

Now I want to search the 2nd file based on matching the naming pattern with the 1st file (note: the outputvalue in the file name is different for both files) and so far followed this method

1) Use a list folder with *.txt pattern to search all the text files and the output is a 1D array
2) then use array to cluster and then flatten to XML function to have all the text file names as a string element (not 1D array)
3) then pass the output of the 2nd step to the sting match pattern and use a regular expression to get the required file name
4) send the output of the 3rd step to search 1D array to get the index and then get the file name and later use read text file to read the content of the text file

And I am stuck at the 3rd step while sending an input as the regular expression to match the pattern as the outputvalue in the namming convention of the above two files is different is there any way I can actually extract the filename/file?

Any suggestions?

 

0 Kudos
Message 1 of 4
(4,264 Views)

You can output the List file function to a For loop with auto-indexing instead of converting to XML.  Why not use a special control character that is part of your naming convention to separate the common elements of the file name such as Die_1_DUT_outputvalue_DD_MM_YYYY(ABC.  You can then search the string for '(' and take the after string element to process.  Searching for this control char, take the Before string element and compare against the File 1.  Can you post your VI?  I can't view your .png.

-----------------------------------------------------------------------------------------
Reese, (former CLAD, future CLD)

Some people call me the Space Cowboy!
Some call me the gangster of love.
Some people call me MoReese!
...I'm right here baby, right here, right here, right here at home
0 Kudos
Message 2 of 4
(4,257 Views)

hi

 

thank u very much for the reply

 

i have modified my VI a little bit by taking 1D array to spreadsheet string rather than using cluster and flatten to XML

 

Please c the attached vi

0 Kudos
Message 3 of 4
(4,250 Views)

Some bits in your code are unnecessary, a leaner implementation here:

find file.png


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 4 of 4
(4,245 Views)