LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read text column by column

Solved!
Go to solution

Hi all,

I've been bothered by this problem for long time. I have a text file in which the different items had been separated by tab column by column.(You can look up the attached file.) And I want to extract each column from the text to do further processes in LabVIEW. I know the read delimited spreadsheet can do such job, but my LabVIEW is too old to have this vi. So please let me know how to do this :(((((  

0 Kudos
Message 1 of 12
(4,371 Views)

You need to read the entire file into memory, then you can transpose if you want to process column by column.

You can either read it as raw string and use "spreadsheet string to array" or directly use "read from spreadsheet file". Both are available in all versions of LabVIEW. ("read delimited spreadsheet" is just a newer version with basically the same functionality. The old one works fine)

 

(Your file has some double-delimiters, so you might get some empty columns. I am sure you can deal with that ;))

0 Kudos
Message 2 of 12
(4,358 Views)

I did use the Spreadsheet string to array, but it turns out to be row by row.(look up the attached file.)

It doesn't seem to split the text based on tab. I don't know why 😞  

Download All
0 Kudos
Message 3 of 12
(4,324 Views)

Tab is the default, so don't wire that. (... And what's the display style of your delimiter constant? Unless it is \-codes the value is wrong!) Could it be your delimiters are spaces? (Sorry, posting by phone).

 

As you can tell, we cannot debug pictures, so attach the actual vi.

0 Kudos
Message 4 of 12
(4,321 Views)

...and if you don't want row by row, transpose it, as already mentioned.

0 Kudos
Message 5 of 12
(4,320 Views)

I'm sorry that I have so many questions 😞

But after transposed, it just changed to a 1*N string array.(look up attached file.)

Please help check my VI.

I will appreciate that sincerely 🙂

Download All
0 Kudos
Message 6 of 12
(4,311 Views)

It because your colunm delimiter is wrong. I have a look at your VI later, currently posting by phone.

0 Kudos
Message 7 of 12
(4,307 Views)

@jiawaichen77 wrote:

Please help check my VI.


Please start with a few turorials before continuing. What would possess you to process the same string millions of times per second. Why do you need a timed loop? Why two loops? Why a local variable?

 

As I said, you delimiter is wrong. You file does not contain any delimiters that have the two characters "\t" in normal display.

0 Kudos
Message 8 of 12
(4,289 Views)
Solution
Accepted by jiawaichen77

This should give you some ideas....

 

Your delimiters is <space>, not <tab>!

 

(Of course "read from spreadsheet file" can do it all in one step, even the transposition if desired.)

 

ReadIt.png

Message 9 of 12
(4,284 Views)

It looks like your file is actually using a space for the delimiter.  And there are some columns that appear to be separated by multiple spaces.  Otherwise, the Read Delimited Spreadsheet does the job.



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 10 of 12
(4,279 Views)