LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read data from txt file respectively

Hi,

 

I am triying to form an equation between two known points. I want to do this with the attached VI, the most critical point is that I will read the x1, y1, x2 and y2 coordinates from the same .txt file. They will be written in a .txt file and I will send them to the appropriate channel (x1, y1, x2 and y2) respectively. How can I get data in a rule from a .txt file?

 

Could anyone please help me with this issue,

 

Best regards. 

0 Kudos
Message 1 of 11
(3,289 Views)

You are almost there.  You just need to index your values out of the 2-D array and wire each one to the respective terminal.

0 Kudos
Message 2 of 11
(3,288 Views)

I have indexed them but it gives another error that expects array indexing in the formula node.

 

 

0 Kudos
Message 3 of 11
(3,273 Views)

You have indexed your 2-D array into 4 1-D arrays.  You need to send it 4 elements.  So you need to wire up another input to tell which row or column of the 2-D array contains your data.

0 Kudos
Message 4 of 11
(3,269 Views)

enable indexing....rt click array node

 

Spoiler
read%20from%20txt%20file[1]_BD.png

 

0 Kudos
Message 5 of 11
(3,268 Views)

Thank you very much,

 

It has worked when I have indexed them.

0 Kudos
Message 6 of 11
(3,255 Views)

Now I have to send data to index array module, in this vi I have send constanat input but I want the formula node to process the data from the 1.txt file row by row so what kind of input should I send to the index array?

 

Waiting for your valuable helps.

 

Best regards,

0 Kudos
Message 7 of 11
(3,231 Views)

Sorry I forgot the 1.txt

0 Kudos
Message 8 of 11
(3,226 Views)

Because your file is fixed length, you should be using a For Loop instead of a While Loop.

 

Set up your Index Array to give you columns.  Then auto-index at the loop tunnels to go row by row (as Apok had mentioned).

0 Kudos
Message 9 of 11
(3,222 Views)

Dear RavensFan,

 

Thank you very much for your helps, I am bit new to labview so I usually can not find the appropriate functions easily. And a new problem has rised in my application. I should write the A, B and C numbers in the respective series to the file 2.txt. I am able to write them in a straight forward case but I want to write the next triples (A B C) in the next row. Like this;

 

A1 B1 C1

A2 B2 C2

A3 B3 C3

.

.

.

 

So how can I put new line constant and space constant to my VI? 

 

Waiting for your valuable helps,

 

Best regards,

0 Kudos
Message 10 of 11
(3,195 Views)