LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

what is the easiest way to read fixed width ascii files?

There does not seem to be an easy way to read fixed with ascii files in labview.  CSV files and other delimited files are easy, but I cannot think of a simple way to read data from a fixed width ascii file.
0 Kudos
Message 1 of 4
(3,441 Views)
The Read From Text File function has an input called count where you can specify the number of characters to read.  Use the function in a loop to and set "count" to the fixed width.  The output of the loop can be an array of fixed length character strings.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 4
(3,435 Views)

continuing from tbob;

... When you read past the end of the file, you'll get an error (4?) indicating EOF. Trap on that to stop the loop and remember the last record from the loop needs deleted.

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 4
(3,430 Views)


@jgkempen wrote:
There does not seem to be an easy way to read fixed with ascii files in labview. 

Reading a file does not depend on its contents. Unless the file is gigantic, you can just read it as one big string and parse it later, especiall if you want the entire contents of the file.

 If you only need a subset, you can calculate the offsets and sizes as multiples of your record size. That's the beauty of fixed size records. 🙂

It is typically not efficient to read a file in a loop, small portions at a time, so I would not recommend that except in some very specific situations.

Could you be a bit more specific on what exactly you need to do? Is your problem with reading or with parsing the fixed sized records? Could you attach a sample file and some description on what you need to read from it.


 

Message Edited by altenbach on 09-05-2007 07:50 PM

0 Kudos
Message 4 of 4
(3,406 Views)