LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Multiple Binary Files and Outputting Multiple Tab Delimited Text Files

Solved!
Go to solution

I have a vi that currently takes a binary file, and converts it to a CSV. I am trying to modify the program to allow for any amount of binary files to be uploaded and converted into individual CSVs. I was trying to use for loops to do this, but I can't quite figure it out. Attached is the original VI.
Thanks for the Help!

 

0 Kudos
Message 1 of 6
(3,345 Views)

Hi MatLac,

 

Maybe it is easier as you think. Try to build an array of file pathes of your binary files and pass it to that modified VI.

Please note the comments.

 

MOJO

Message 2 of 6
(3,321 Views)
Solution
Accepted by MatLac

I would slightly alter MOJO's algorithm:

  • I would keep using an Array of Binary-Filenames-to-Process.  I would also recommend that they share a common extension (I'm doing to assume you are using ".bin", which suggests "binary", rather than ".txt", which suggests "text".
  • Instead of change the Filename of the CSV output files, I would use the same Filename and change the Extension.  The easy way to do this is as follows:
    • Use Strip Path to isolate Folder Path (save for later step) and Filename.
    • Use Match pattern with ".bin" (or whatever extension you are using).
    • Use Concatenate String to add the new extension, ".csv".
    • Now combine new Filename with old Folder Path using Build Path.  Use this as the input Path for Write Delimited Spreadsheet.

Do you know how to programmatically get a list of all the files of a certain type in a Directory?  Let's say you have a folder "C:\My Data" that has all of your ".bin" files inside, and you want an array of the paths to all of these files (to use as the input to the algorithm discussed above).  Here's what you do:

  1. There's a function on the Advanced File Functions called List Folder.  If you give it a Path to a folder, it will return the Path and two arrays, one of all the Files in that Folder and one of all the sub-Folders in that Folder.  You can specify a "Pattern" (such as "*.bin") to specify what Files you want to include.
  2. Take the Folder Out and the Array of Files and pass them through a For Loop that does a Build Path to combine Folder with Filename and you have your Array of Binary Files to run through the above Algorithm and create corresponding .CSV files.  [Note that you could, if you wished, save the .CSV files in a sub-folder that you create inside C:\My Data -- I'll leave the details to you to figure out.]

Bob Schor

Message 3 of 6
(3,275 Views)

I've been trying to make the changes you recommended but I don't think I quite understand how to do what you are saying. Right now I am using the List Folder vi to get the file paths, as well as a count to know how many iterations to run. I understand that the strings outputted don't match the file path format needed to be inputted into MOJO's algorithm but how do I make it so those strings are converted to file paths? Thanks for the help and sorry for the confusion.

0 Kudos
Message 4 of 6
(3,248 Views)

Never mind that last reply of mine, I figured it out, I have attached the working vi if anyone needs to see it for reference in a similar problem. 

0 Kudos
Message 5 of 6
(3,237 Views)

Depending on how big your file is, you may run into memory problems.

 

No idea if this is any better, but it takes up less space on your block diagram and may be preferable to your solution now. It also may be slower and use more memory, you would need to test.

 

mcduff

 

Use this for your conversionUse this for your conversion

Original Conversion LoopOriginal Conversion Loop

0 Kudos
Message 6 of 6
(3,230 Views)