LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Textfile into Array

Hi!

 

I'm a total beginner in labview so I'm struggling with easy things 🙂

 

I have a textfile which looks somehow like this:

 

[Inficon XTC Material File]
Date=123
[Material1]
Source=Aluminium
Chem=Al
Density(0.01g/ccm)=270
ZRatio=1080
RiseTime1(s)=10
SoakTime1(s)=5
RiseTime2(s)=10
SoakTime2(s)=10
SoakPower1(%)=7
SoakPower2(%)=11

 

The plan is to read the file and write it into an array, line by line. I'm able to read the txt file but not to get the lines into an array. I only get the first line 🙂

 

To give you an idea what I have to do:

The informations are from an old coating controller and I have to write a software for the new controller. And for this reason I plan to use the old files with the old data (there are several of them) and manipulate them in a way that the new controller is able to understand. At the end I have to take the values and combine them with the corresponding command before sending them to the controller.

0 Kudos
Message 1 of 13
(272 Views)

Hi Martin,

 

It looks like a configuration file.

Maybe you could try something like this :

PinguX_0-1736776915490.png

 

0 Kudos
Message 2 of 13
(249 Views)

Hi PinguX

If i get it right, like that I would have all the values taken out from the file and have them as values? This is somehow helpful but the file itself contains many many of this parameters for several materials. And the same for a bunch of so called recipes. That's why I had the hope to work with arrays to get it somehow a bit "compressed" without touching each line separately.

 

My idea was:

Read the file -> feed it into an array -> split it in a way that I only get the values -> ad the command to each value -> send it to the controller

 

Or do I think to easy?

0 Kudos
Message 3 of 13
(220 Views)

Please see attached what I try...

Download All
0 Kudos
Message 4 of 13
(213 Views)

When you want to go that way you should use = als delimiter and look at the second column of the array (Index Array).

 

But:

- What happens to the string values like Al, Aluminium, ... ?

- You loose the information where the value belongs to. What happens if the lines in the file are not in the expected series of key words?

0 Kudos
Message 5 of 13
(194 Views)

If you really want the file as an array, use "=" as the column separator and LabVIEW will use "\n" as the row separator.

 

PinguX_0-1736783746943.png

 

Message 6 of 13
(189 Views)

You are really close.  Connect an empty string array constant to the array type input to keep Spreadsheet String to Array from defaulting to numeric output.

 

Note that I also used the newline constant for the delimiter.  I thought \n would work, but it doesn't for some reason. 🤔

NIquist_0-1736784128117.png

NIquist_1-1736784142931.png

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 7 of 13
(179 Views)

If you just want a list, you can configure read text file to read lines instead of characters. A value of -1 reads all lines.

cordm_0-1736784875095.png

 

Though what PinguX showed is probably further along what you actually want.

 

If each material has the same properties, you can use the config file approach looping over the file sections.

 

0 Kudos
Message 8 of 13
(166 Views)

@PinguX wrote:

If you really want the file as an array, use "=" as the column separator and LabVIEW will use "\n" as the row separator.

 


Interesting! I didn't know that and it doesn't say in the help text, but there is a note in the Example. 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 13
(165 Views)

Good morning everybody!

 

I think the Solution of @PinguX might work for the further processing and I'm close to it.

 

What I get are the numbers in the second row but not the text. And my array has the wrong "color" and shape. I guess that's a mater with the data format. Maybe that's a foolish question but where the h..l do I change that? 🤔

0 Kudos
Message 10 of 13
(132 Views)