03-31-2020 01:17 AM
Hello,
the attached .vi make read files from a folder, make some calculations and save the output file of each input.
currently, I save the files one by one and I have to name every output file because of the saving items already inside the loop.
How can I make the saving process automatically and the output files take the same name of the input files? just in a different saving path folder!
for example, the input files take the names file1, file2,...
Solved! Go to Solution.
03-31-2020 01:52 AM - edited 03-31-2020 01:54 AM
Hi Khallod,
@Khallod wrote:
currently, I save the files one by one and I have to name every output file because of the saving items already inside the loop.
How can I make the saving process automatically and the output files take the same name of the input files? just in a different saving path folder!
The WriteDelimitedSpreadsheet function has several inputs, one of them the "file path" you left unwired. Because of this you are asked to provide a filename using a file dialog with each iteration. What will happen once you create the filename programmatically?
Use file path functions (like StripPath and BuildPath) to create a filename for the file storing the calculation results!
There also is a CreateFolder function in case you need to create this "different saving path folder" first…
Hint: never hide terminal labels in the block diagram, this is considered to be bad coding style…
03-31-2020 01:52 AM
I hope your Problem seems to be very simple, Since i am working with LV 2017 I am not able to access the attached VI Will be better if you can share with LV 2017 or lesser.
Just Strip File Name from input file path and Build with the different Folder Structure of the Output file and save accordingly.
03-31-2020 06:11 AM
I make something like that but still doesn't give me the expected results
03-31-2020 06:17 AM - edited 03-31-2020 06:19 AM
Hi Khallod,
The input that GerdW meant is the one to the Write Delimited Spreadsheet node.
You can use the same technique you're using for the Read node - pass the string input at the loop to a (new) Build Path node, with a Path Constant for the directory you want to save into.
This will create a (new) path to a (future) file in the directory with the same name as the input file.
You can connect that to the Write Delimited Spreadsheet node and you won't get the prompts anymore.
03-31-2020 06:29 AM
Now it is working,, Thanks alot
03-31-2020 08:48 AM - edited 03-31-2020 09:11 AM
This is the last version of the .vi, maybe one of the users need to make something similar.
I would like to ask another question.
If the input path contains different types of data files, how can we modify the code to read only the files under the names file-001.txt, file-002.txt, ...
03-31-2020 11:04 AM
@Khallod wrote:
This is the last version of the .vi, maybe one of the users need to make something similar.
I would like to ask another question.
If the input path contains different types of data files, how can we modify the code to read only the files under the names file-001, file-002, ...
You can use the "Pattern" input to your List Folder call to limit the files that are returned.
In that case, "file-???.txt" or similar might work. You can use * for any number of any character, and ? for one character (any character), but the node doesn't support full regular expressions.
If the Pattern input isn't enough for you, you could try getting all of the files and then using something like Match Pattern or Match Regular Expression to see if the filename matched a more complicated pattern.
04-01-2020 03:48 AM
Hi,
I am trying to use the attached code, I found it here in the forum.
My question only outside the loop. If the input folder contains many types of data files. How can I read only specific files?
for examples the files under names Detector1-001.txt, Detector1-002.txt, Detector1-003.txt, ......
04-01-2020 03:58 AM - edited 04-01-2020 04:01 AM
Hi BaJa,
please discuss this with your collegue Khallod!
As you are using the very same VI like him/her I guess it also helps to merge your threads…