LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert multiple files to .txt

Solved!
Go to solution

Hello everyone!

 

How can I convert multiple files to ".txt"?

 

I was able to achieve this by creating this workflow but for each conversion, it asks me to select the file to convert and then to select the folder where I want to output it. Is there a smarter way to perform this conversion? 

 

The files are named: " 1_good ", " 2_good ", " 3_good ", " 4_good ", " 5_good "...

 

Thank you in advance for your help!

 

PS: I've also uploaded my algorithm, called " ConvertFIle.vi "

Download All
0 Kudos
Message 1 of 21
(3,179 Views)
Solution
Accepted by topic author JackRen3

Use list folder with a suitable pattern (or generate the filenames based on incrementing numbers) and iterate with a FOR loop. What is the extension of the input files? Make sure you exclude the output files in the match.

 

Here's a quick draft to get you started:

 

altenbach_0-1600185603475.png

 

Message 2 of 21
(3,173 Views)

The file doesn't have an explicit extension. I couldn't identify it.

 

This is my first day using LabView, I couldn't find all the functions that you used, like the one after the block "file.txt".

 

Could you help me?

0 Kudos
Message 3 of 21
(3,158 Views)

This is what I could reproduce.

0 Kudos
Message 4 of 21
(3,157 Views)

Hi Jack,

 


@JackRen3 wrote:

This is my first day using LabView, I couldn't find all the functions that you used, like the one after the block "file.txt".


It's a string function, found in the string functions palette…

When it is your first day with LAbVIEW you should start with the Training resources offered in the header of this LabVIEW board!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 21
(3,136 Views)

I started looking on the documentation but I was hoping anyone here could help me to understand how to perform this task.

 

I was able to reproduce the suggestion given to me but I don't understand how I should make work the "for loop" and how to let the algorithm choose the files iteratively. I run the algorithm, it asks me to select the folder but then it doesn't work, it seems it doesn't select the files. I know that something in the workflow is missing but I don't know what.

 

Thank you again for your help

 

0 Kudos
Message 6 of 21
(3,095 Views)

What's the size of the array of filename coming out of "list files"? If there are no matching files, the loop will iterate zero time. Can you attach your VI?

 

0 Kudos
Message 7 of 21
(3,077 Views)

Here it is my VI.

 

With size of the array you mean the number of files to output? If so, i have to convert 475 files and at the output I want those files to be in .txt, so I need 475 files again.

 

Thank you very much for the support.

0 Kudos
Message 8 of 21
(3,060 Views)

Simple troubleshooting:

 

I meant wire an "array size" to the array coming out of "list folder". If things are correct, the size should be around 475, but if the pattern is wrong, it could be zero. You also might want to create an indicator to the iteration terminal to see what's happening. Are you sure you are selecting the correct folder?

 

Can you attach one of the data files here? (Place it in a zip file so the forum does not reject it).  Does it have unicode or other unusual characters in the filename?

0 Kudos
Message 9 of 21
(3,042 Views)

Thank you, your solution above worked and I could perform the conversion for all the files.

 

My last question is this:

 

In my folder I not only have files called "NUMBER_good" but also files named "NUMBER_warning" or "NUMBER_bad".

How can I help the program to understand that multiple names in the folder are possible?

 

An example of a list of files in the folder is:

1_good

2_good

3_warning

4_good

5_bad

6_warning

...

 

 

Thak you in advance

0 Kudos
Message 10 of 21
(2,907 Views)