LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

save the output files with the same of the input files

Solved!
Go to solution

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,...

0 Kudos
Message 1 of 18
(3,469 Views)

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…

Best regards,
GerdW


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

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.

----------------------------------------------------------------------------------------------------------------
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 3 of 18
(3,453 Views)

I make something like that but still doesn't give me the expected results

0 Kudos
Message 4 of 18
(3,416 Views)
Solution
Accepted by topic author Khallod

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.

rePath.png


GCentral
0 Kudos
Message 5 of 18
(3,411 Views)

Now it is working,, Thanks alot

0 Kudos
Message 6 of 18
(3,407 Views)

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, ... 

0 Kudos
Message 7 of 18
(3,384 Views)

@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.


GCentral
0 Kudos
Message 8 of 18
(3,365 Views)

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, ......

 

0 Kudos
Message 9 of 18
(3,341 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 18
(3,331 Views)