09-26-2019 11:11 AM
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 :(((((
Solved! Go to Solution.
09-26-2019 11:23 AM - edited 09-26-2019 11:35 AM
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 ;))
09-26-2019 12:25 PM
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 😞
09-26-2019 12:31 PM
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.
09-26-2019 12:33 PM
...and if you don't want row by row, transpose it, as already mentioned.
09-26-2019 12:59 PM
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 🙂
09-26-2019 01:08 PM
It because your colunm delimiter is wrong. I have a look at your VI later, currently posting by phone.
09-26-2019 02:20 PM
@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.
09-26-2019 02:32 PM - edited 09-26-2019 02:36 PM
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.)
09-26-2019 02:36 PM
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.