From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read Data

Solved!
Go to solution

How can the following file be parsed to fill a cluster as attached?

The county are separated by blank line and that indicates the next array of Item Parsed cluster.

Download All
0 Kudos
Message 1 of 3
(2,268 Views)
Solution
Accepted by topic author ts_2012

First of all, you don't need to get the file size.  Leave the read size unwired and it will read the entire file.  Also make sure to close the file.

 

Ok, let's take this 1 step at a time.  First you want to get an array of the county data.  Since the counties are separated by a blank line, you should use the Spreadsheet String to Array with two end of line characters as the delimiter (put string constant in \ display mode and use "\n\n").

 

So now we have to figure out how to parse the county data.  Use the Spreadsheet String to Array function again, this time with a single end of line character as the delimiter.  This separates the county data into lines.  The first line is the county name, second the largest city.  Run the rest of the array into a FOR loop, parse the string with a tab as the delimiter, and build you cluster.

 

Clear as mud?  If you take it 1 step at a time, it is not that bad.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 3
(2,212 Views)

Thanks, taking one step at a time did help;)

I used regular expression and then the for loop to iterate and fill the data.

0 Kudos
Message 3 of 3
(2,182 Views)