LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extract Matched Data from CSV or XLS

Solved!
Go to solution

Hello all,

 

I have a file I can download into either a CSV or a XLS file. I then want to take the file which contains customer data (Name, company, address, city, state, country, email, phone, etc) and separate the customers that are in the US and those that aren't in the US. I've been able to import the entire XLS into labview as a 2D Array, but I'm not sure how to separate the US and Non-US customers and return the results back to an excel template.

 

Attached is an excel file with test data. The excel file will always vary in size, but the columns will always be the same.

 

Thanks all!

0 Kudos
Message 1 of 10
(3,272 Views)

So you want to sort the data, and then write it back to Excel?

 

Lots of ways to do that in LabVIEW.  Try running the array through a FOR loop and then check the value of the country column (conditional) and append to a new array inside a case statement.

 

But its way easier to do that in Excel.  In fact, it too me 6 mouse clicks.

 

Is this data being produced from a DB export?  If so, you should just add a SORT BY command to the export routine.

http://www.medicollector.com
0 Kudos
Message 2 of 10
(3,261 Views)

I don't want to sort the data. I want to separate the US and non-US customers and then export them into separate Excel templates.

 

It's being downloaded from a marketing website. I've tried running it through a FOR loop but it doesn't return the values before the "Country" column. Also, I want to write a LV program because I want the program to send emails to all the customers as well as send the XLS files to specific users. For example, non-US file to one person, US file to another person.

0 Kudos
Message 3 of 10
(3,256 Views)

OK.

 

To do that in LV:

 

Run the 2D array through a FOR loop using auto-indexing.  So for each iteration of the FOR loop, the auto-indexing will pull out a 1D array (the relevant row).  Then you need to index the appropriate column from that row and process the conditional logic.

http://www.medicollector.com
Message 4 of 10
(3,250 Views)

josborne,

 

This is where I am so far. The VI searches and returns only one row from the file that contains the string I enter. However, I want it to return every row that contains the string I enter.

 

Thanks again

Extract.png

0 Kudos
Message 5 of 10
(3,232 Views)

Use build array and a case statement (or a conditional array tunnel in LV 2012) to add only the elements that match your criteria.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 10
(3,225 Views)

Hi Mark,

 

Do I still use the "Search 1D Array" function or is there a better way to do it? I'm not sure exactly how to code that. By any chance, can you provide an example? Thanks for your help

0 Kudos
Message 7 of 10
(3,199 Views)
Solution
Accepted by topic author buickgn

You don't need to use search array (though it would be a faster and clever way to do it).  The simple way to do it is this:

 

snippet.png

 

 

http://www.medicollector.com
Message 8 of 10
(3,189 Views)

BTW:  You seem like you could use some training in the basics. 

 

No offense, but you might want to start here:  http://www.ni.com/academic/students/learnlabview/

http://www.medicollector.com
0 Kudos
Message 9 of 10
(3,188 Views)

Josborne,

 

I appreciate it. I actually had this before I posted, but it wasn't reporting the correct results so I assumed it had something to do with the way I was reading the XLS file. Thanks for putting me on the right track, I'll keep at it. I actually have been to the first 2 core courses, just trying to get acquainted with arrays.

 

Take care

0 Kudos
Message 10 of 10
(3,183 Views)