02-02-2020 08:26 AM
Hi guys, I am new with LabVIEW and i need some help to get starded.
I have a folder with a lot of .txt files.
1) First of all i have to find a way to open all them sequentially.
2) For each file i have to extract the name of the file opened and the value of the streses detected (SF PR [T]) and then i have to do a moving average with 2 elements and find the maximum and minumum value.
3) repeat the step #2 for each .txt file.
4) create an excel file/ csv file with the name of the file, the maximum value and the minumum value
ATTACHED YOU CAN FIND AN EXAMPLE OF THE .TXT FILE
thanks a lot
02-02-2020 09:08 AM - edited 02-02-2020 09:09 AM
Use List Folder function to get all the txt files from the folder then use a For Loop to open each file and get the data out. Your txt file seems to be of spreadsheet type with ";" delimiter so you can read them using Read Delimited Spreadsheet.vi. Find a way to get the SF PR [T] data out of the whole 2D array. If stuck, ask again for help but attach the VI so we can see what have you tried so far.
02-02-2020 09:46 AM
Hi Gquadro,
LucianM already pointed out how to get a list of files and pass their paths to a For loop: use List Folder together with a pattern (*.txt) and then an autoindexing tunnel.
That solves your point #1.
For #2, you can use Strip Path to take just the filename. If you want it without the extension, take a look at the Get File Extension VI which outputs (from a path) the filename without extension as one of the outputs. You could optionally open this VI to see how it works, and copy only the parts you really need if you prefer.
The For loop covers #3.
For #4, you can use an autoindexing output of either a Cluster or an array of strings - if you convert your values to strings within the loop it will be easy to use Write Delimited Spreadsheet to create a CSV file from the 2D array of strings (build a 1D array inside the loop of name, max and min, then the output of the For loop will be a 2D array for WDS).
You can do #2's b) part (SF PR [T]) by either matching the column names and looking for one with the key you want, or if they are always the same order and number of columns, simply using Index Array. Using a matching algorithm will make it a bit more self-explanatory, but will cost some tiny amount of time.
02-02-2020 09:46 AM
Hi!
Thanks a lot for your help.
I attach what i have done; now i have to extract "SF PR [T]", could you help me?
02-02-2020 09:56 AM
02-02-2020 10:20 AM
could you share with me your code?
02-02-2020 10:31 AM
02-02-2020 10:40 AM
LabVIEW Robotics 2019
it is a png, and if i drag it into Labview it appears a link
02-02-2020 10:47 AM
Snippets are a bit.... finicky. You have to open the preview window and use the download button (which has no icon). Then the saved png can be dragged into LabVIEW to generate code.
Use the indicated button from the original post.
02-02-2020 10:50 AM
If you have it downloaded, it should be possible to drag from Windows Explorer to the block diagram and place the code. If you don't do it correctly (it can be fairly fiddly - I'm not sure what the best tips are) then you might get a picture instead. But it is possible to drop the code.
In any case, the VI is attached to this post, which may or may not be easier.