LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert .ini file to cluster?

Hello!

I have a .ini file and would like to convert it to cluster and use the data within LabVIEW
The tables/arrays are dynamic and can be larger or smaller, I tested with several ways and could not solve the situation to meet all cases

 

I've attached the .ini file and the Vi I'm building

Download All
0 Kudos
Message 1 of 15
(725 Views)

Please do a "save for previous" (LabVIEW 2020 or below and attach your VI again.

 

Clusters are fixed size and defined at compile time. Why does it need to be a cluster?

Maybe you can define a cluster will all possible fields, then only use some of them?

Message 2 of 15
(716 Views)

Oh, I asked if it was a cluster because of how easy it is to work with

But if there's another way I don't see a problem

0 Kudos
Message 3 of 15
(708 Views)

So what exactly do you need at the end?

 

I was confused by your convoluted code, here's maybe a simpler way to read the data as 2D array for further processing.

 

How is this data used later and how does your array diagram constant fit into the equation?

One possibility would be to build a MAP (key/value pairs)

 

altenbach_0-1711492860499.png

 

0 Kudos
Message 4 of 15
(691 Views)

It looks like whoever wrote the INI file is using MGI's Read Write Anything. You can use their library to convert the ini file to a cluster. You will need to define the cluster that you want from the INI file; it is supposed to be the same cluster that was used to write the file. I do not remember how it handles missing fields, errors, etc.

Message 5 of 15
(653 Views)

Hello

you can't create a cluster from a text file. Or you need scripting.

 

But you can manually create a cluster, and the manually set every value.

 

You can read INI file with Labview VIs "Configuration":

 

Walker34_0-1711539736458.png

 

And this example : 

  • labview\examples\File IO\Configuration (INI)\Configuration (INI) File.lvproj
0 Kudos
Message 6 of 15
(603 Views)

This is a job for LabVIEW Scripting.  It absolutely is possible to get LabVIEW to (a) look at a data structure, (b) analyze and figure out what types it contains, (c) use "other means" to create meaningful "Cluster names" for the putative Cluster Elements, and then (d) create the Cluster.  I did this in one of my first major LabVIEW projects, taking an Excel WorkSheet whose column headings became the "name" of a Cluster element and whose type was determined by analyzing the contents of the data contained in that column (from a Master WorkSheet that had "sample data" that could be analyzed to determine if it was a Dbl, I32, Boolean, String, or (other things I don't remember now).  I made a Cluster (>100 elements!) that I could read an entire WorkSheet row into, and then when I needed, say, "Elevation", I would Unbundle by Name and get the Dbl value it contained.

 

Go to the Web and search for LabVIEW Scripting Tutorial.

 

Bob Schor

0 Kudos
Message 7 of 15
(589 Views)

@mcduff wrote:

It looks like whoever wrote the INI file is using MGI's Read Write Anything. You can use their library to convert the ini file to a cluster. You will need to define the cluster that you want from the INI file; it is supposed to be the same cluster that was used to write the file. I do not remember how it handles missing fields, errors, etc.


I second the motion for MGI Read Write Anything which I've been using for almost 20 years now.

 

Fields that are missing in the .INI file will either be assigned the datatype's default value (0, False, empty string, etc) OR you can optionally provide a cluster of default values as an input wire.

 

Remember to make your cluster into a typedef!  (Right-click cluster boundary, "Make Type Def", then save.)  Beware if manually editing -- it does not like extra whitespace around the '=' assignment.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 15
(568 Views)

Really, the .ini file was created using MGI Write Anything
I was trying to convert the ini data using that (MGI Read Anything), but i couldn't

Updated files, with the creation of typedef

Download All
0 Kudos
Message 9 of 15
(564 Views)

You can use my Ini-handler

Solved: Re: Read/Write INI Cluster OpenG - NI Community

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 15
(524 Views)