LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data from excel to array

Solved!
Go to solution

 


@AndreaD wrote:

 

Sorry, I'm not sure if I can post my code online due to policies of the agency I'm working with.

 

Thanks,

Andrea


If you could make a quick skeleton VI that shows us what you're trying to do without giving away any state secrets Smiley Surprised that would help us help you.

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 11 of 22
(2,239 Views)

Also, as a previous post asks, is this an actual Excel spreadsheet, which uses a proprietary format of data, or a text file that uses comma separated values, or tab delimiters? There is a difference, which requires different tools. But as mentioned you can load an front panel display programmatically. Using a cluster may not be the way to go, unless your data format won't change.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 12 of 22
(2,232 Views)

Essentially what I'm trying to do is to create a cluster, which will read and pass along a large amount of data. The data format can be an excel file, a spreadsheet, text file, or whatever means to read the amount of data. I have the flexibility of copy-pasting the data, or I can just upload it, whichever way is easiest.

 

Currently, I have an array in the cluster, which I would have to manually enter the data in, and is not a feasible option for a large amount of data.

 

Sorry for the confusion this has caused ... I've included a brief sketch of what I mean. It's easier than how I worded this in the previous two posts 😛

 

Thanks,

Andrea

0 Kudos
Message 13 of 22
(2,223 Views)

That picture conveys almost nothing in terms of information. All I see is a box with another box and an arrow. No information on datatypes. Unless you provide a better explanation, I don't see why you can't just use a 2D array at this point.

0 Kudos
Message 14 of 22
(2,216 Views)

Currently, I do have a 2D array with 8 bit unsigned integer. I don't think I can copy/paste a large amount of data into a 2D array.

0 Kudos
Message 15 of 22
(2,212 Views)

 


@AndreaD wrote:

Currently, I do have a 2D array with 8 bit unsigned integer.


 

Is that what your data actually is?

 

 


I don't think I can copy/paste a large amount of data into a 2D array.

 

Why not? What problem are you actually running into when you try it? Where are you copying the data from?

 

 

If you're trying to populate some front panel control and the source of data can vary then you need to better explain whether this is an action that you're trying to perform while you are editing a VI or when the VI is running. If it's when it's running, then a better approach is to provide a file path control with a button to read the file. If you want to support multiple file formats then you would need to determine the file type (such as by looking at the extension), and call the VI to read the file and return the data which you can then write to your front panel control. If it's an Excel file then you need to use ActiveX. There have been tons of examples posted on read/writing Excel, so just search and you'll find them. There's also the Excel thread for additional links. If it's a text file then you can simply use Read From Spreadsheet File if you have a delimited text file. Alternatively, you could limit the files your program can read to simply being delimited text files. This makes your life easier, but it would require someone else to create the appropriate file type (such as saving from Excel to a text file).

0 Kudos
Message 16 of 22
(2,201 Views)

You need to be a little more specific as to how you want to import the data. The reason that I say that is because there are a number of different ways to do this. If it is a text file or a tab delimted file then you can use pure G functions but if it is in excel then it gets a little trickier and not as easy to do since you would have to have a special toolkit or you would have to learn how to use Active X. To write a program to use all of these could be done but it would make it a lot easier on you if you would define the data structure first (ie Excel spreadsheet or tab delimited text file, etc...) and then import it in to LV




Joe.
"NOTHING IS EVER EASY"
0 Kudos
Message 17 of 22
(2,199 Views)

OK, now I see.  This is a very common thing in LV.  You already have a data structure (a cluster) that has a 2-D array of raw data and some other things (process variables or whatever) that you are also storing in the cluster to keep things tidy.

 

Here is a simple example:

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 18 of 22
(2,197 Views)
Solution
Accepted by topic author AndreaD

Ugh, I didn't know there was a time limit on editing your posts!  What a pain that it doesn't even give you a chance to save what you've already written. Smiley Mad

 

Anyway, it's true there's extra crap in an actual EXCEL (.XLS from MicroSoft) file.  Just save it as a tab delimited text file first. Then you can read it with the simple LV tools.  Otherwise you'll need ActiveX or the Report Generation Toolkit, which unfortunately kind of sucks. Smiley Sad

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 19 of 22
(2,183 Views)

Apparently after hearing the same answer for the third time we've come to an accepted solution of just dealing with a text file... Kudos to all who repeated the same thing...

Message 20 of 22
(2,154 Views)