LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read specific number from txt file

Solved!
Go to solution

Hi,

Is anyone know how to read specific numbres from a txt file.

If the operator choose tab1. The values displayed will the first list of numbers. If not the values displayed on the table are the second list

Thank you in advance for your help

Please find enclosed my VI and the txt file

My best regards

Nadia

Download All
0 Kudos
Message 1 of 6
(4,106 Views)
Solution
Accepted by topic author k.nadia

Do you require the format that your example tab.txt file is in?

 

If not, I would consider using a format such as LabVIEW's Config File VI's or a common standard such as XML.

 

If you do require the exact format in the example, then you may have to write your own parser for it.



0 Kudos
Message 2 of 6
(4,082 Views)

Thank you for your reply,

I don't require this format. But at the same time I don't see how can I extract my values using the formats you suggested

Could you possibly give me an example

Thank you in advance

My best regards

Nadia

0 Kudos
Message 3 of 6
(4,075 Views)
Solution
Accepted by topic author k.nadia

Do you have control over the format of the text file? If so I would change it format to make it easy to read in.

If you do not have control over the text file, your best bet is to read in the whole text file and then parse the [tab1] and [tab2].

 

The "Read From Spreadsheet File.vi" takes to inputs. One is the "number of ROWS (all:1).

The other is "start of read offset (CHARS.:0)"

One is ROW the other is CHARS. Very hard to make that work for you.

 

ReadTab.png

 

Omar
0 Kudos
Message 4 of 6
(4,067 Views)

@k.nadia wrote:

Thank you for your reply,

I don't require this format. But at the same time I don't see how can I extract my values using the formats you suggested

Could you possibly give me an example

Thank you in advance

My best regards

Nadia


For example, using the Config File VI's, you could have each of your "tab1", "tab2", ... be a key under a common section.  The data type could be a binary string (the Config File VI's do not support arrays natively, so you would flatten your array to a binary string for storage).

 

Get Key Names.vi could get you a list of all of your options.  The user selects one from the list, then you use Read Key.vi on that key and unflatten the result to your array.



0 Kudos
Message 5 of 6
(4,046 Views)

Thank you for your answer

I tried it and it works fine

My best regards

Nadia

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