LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting Text From Latest Generated Text File

Solved!
Go to solution

My code is creating log files in specific folder Report every time I run the code and text files are named in the format: %d %m %y____%H %M %S.txt. For Example: 09 07 24____14 50 03.txt.
I want to extract some text from the latest generated text file and display it on front panel. I am using List Folder.vi to extract the names of every text file in the folder. How can I proceed further. Kindly guide me. I am Using LabView 2017.

0 Kudos
Message 1 of 4
(271 Views)

Hi qureshi,

 


@qureshi000 wrote:

My code is creating log files in specific folder Report every time I run the code and text files are named in the format: %d %m %y____%H %M %S.txt. For Example: 09 07 24____14 50 03.txt.


I recommend to change the filename formatting to %Y%m%d_%H%M%S (without spaces, year before month before day): it helps when sorting the files…

 


@qureshi000 wrote:

I want to extract some text from the latest generated text file and display it on front panel. I am using List Folder.vi to extract the names of every text file in the folder. How can I proceed further. Kindly guide me.


Once you got the array of filenames you can convert their filename back to a timestamp and search for the latest timestamp: you KNOW the filename formatting!

 

(If you would follow my suggestion for filename formatting you could even sort the array of filenames and pick the first or last element after sorting…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(252 Views)

Once you got the array of filenames you can convert their filename back to a timestamp and search for the latest timestamp: you KNOW the filename formatting!

 

(If you would follow my suggestion for filename formatting you could even sort the array of filenames and pick the first or last element after sorting…)

Kindly explain it by implementing it in LabView.

0 Kudos
Message 3 of 4
(248 Views)
Solution
Accepted by qureshi000

Hi qureshi,

 


@qureshi000 wrote:

Kindly explain it by implementing it in LabView.


  1. Change the formatting of your filenames as suggested: do you really need help in editing a string constant?
  2. There is a function to sort a 1D array and a function to index array elements: do you need help in wiring those functions?
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 4
(219 Views)