From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save array from text file input

Solved!
Go to solution

Hello, I'm very new to LabVIEW, so apologies if I use the wrong terminology.

 

I have made a VI that reads 25 text files into a 3D array.  When I click run I need to select the 25 text files.  Is there a way I can save the data imported for later calculations without having to select the files every time?

 

Here is what I've got:

Capture.PNG

0 Kudos
Message 1 of 7
(3,527 Views)
Yes there is... In fact, there are many, many ways...

I could rattle off a bunch of techniques, but if you are the newbie that you say you are the list would be largely meaningless. It will be more useful to you to start at the beginning:

What are you trying to do? How will the data be used? How big are the datasets? What do you need to do with the results of your processing? Where are the files located? How are the different datasets identified?

And about you: What skills do you already have? What have you done before?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 7
(3,507 Views)

I'm making a PV solar assessment tool, whereby the user enters their system information (in this case, Zone in UK, panel inclination, and panel orientation).  I need their entry to index this 3D array to find a value for later calculations.  The zone corresponds to what I would call the 'sheet' of values (3rd dimension), the orientation corresponds to the column number, and the inclination the row number.  

 

I have 25 small text files, with 10 columns X 45 rows of numerical values.  I want the data in saved in LabVIEW so when the user clicks run, they don't then have to enter all the text files themselves.  I can get the values in using my VI Iby running and selecting the text files (.txt), but when I close the VI, the values dissappear, I just want them to stay there.

 

I am at a very basic level, as you can probably tell.  But once, I've got this sorted I can repeat for all my other factors.

0 Kudos
Message 3 of 7
(3,494 Views)

What I would do is when the user enters their zone, you then read the file that corresponds to that zone.  You can then use the 2D array as you need.  On startup, read from the file for whatever value is in the zone control and you will have the latest.  No need to keep a lot of memory hanging around.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 7
(3,480 Views)

Thanks for this.  But the user will not have access to these files when running the VI.  There are lots of other arrays that I will need to save and index for other variables as well, so just the method of you'd use would be handy to know.  All I really need is a way of saving these relatively few values into an array.

0 Kudos
Message 5 of 7
(3,471 Views)
Solution
Accepted by topic author Dan_Owen101

@Dan_Owen101 wrote:

Thanks for this.  But the user will not have access to these files when running the VI.  There are lots of other arrays that I will need to save and index for other variables as well, so just the method of you'd use would be handy to know.  All I really need is a way of saving these relatively few values into an array.


Then do you plan on having these values hardcoded in your executable?  That sounds dangerous and prone to you having to make updates a lot.  Trust me when I say that you want to have the files sitting with the executable.

 

But if you are insistant on this, I would use a global variable.  Have a VI just read all of the files and build the array for you and write to the global variable.  Then you can right-click on the control on the global variable front panel and "Make current value default".  Save the variable and build your executable.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 7
(3,461 Views)

Thanks.  The values won't be changing so this is what I needed.

 

Thanks for your time!

0 Kudos
Message 7 of 7
(3,445 Views)