05-03-2023 09:37 AM
Hello,
So I currently have a program that will search a pre-existing excel document (.csv) for a specified carrier number (cell value x). Once it finds the most recent carrier number it will display the part number associated with said carrier. I want to modify my code to allow me to search for the carrier number, and display the entire row (associated with that number. So say I search for carrier number in Column B, instead of just displaying the part number in Column E, I want to display the Row the data is located (A1:E1). Whether as a string or an array, I am just not sure how to go about setting it up.
I attached the VI I currently have as a mock up that ONLY searches for the part number. To run the VI you'll need to change the Path to save dialog in the VI front panel.
Solved! Go to Solution.
05-03-2023 09:39 AM
If someone needs an earlier version of the labview vi, just lmk and I will save it as a previous version.
05-03-2023 09:49 AM - edited 05-03-2023 09:53 AM
How about something like this?
05-03-2023 09:57 AM
@paintman wrote:
Hello,
So I currently have a program that will search a pre-existing excel document (.csv) for a specified carrier number (cell value x). Once it finds the most recent carrier number it will display the part number associated with said carrier. I want to modify my code to allow me to search for the carrier number, and display the entire row (associated with that number. So say I search for carrier number in Column B, instead of just displaying the part number in Column E, I want to display the Row the data is located (A1:E1). Whether as a string or an array, I am just not sure how to go about setting it up.
I attached the VI I currently have as a mock up that ONLY searches for the part number. To run the VI you'll need to change the Path to save dialog in the VI front panel.
Hello Paintman,
If the file is of .csv (not excel) I recommend you use read delimited file and read all data.
If you still want to handle with excel, you can use as array (2D Array) and extract data using Array functions,
05-03-2023 10:11 AM
What array functions are you using in this?
Would I need to place this in my case structure with the file path linked to it? I have never used the file I/O functions before.
05-03-2023 10:28 AM
@paintman wrote:
What array functions are you using in this?
Here's a snippet of block diagram with the labels turned on
@paintman wrote:Would I need to place this in my case structure with the file path linked to it? I have never used the file I/O functions before.
Basically yes
05-03-2023 10:33 AM
@paintman wrote:
What array functions are you using in this?
Would I need to place this in my case structure with the file path linked to it? I have never used the file I/O functions before.
Hello Paintman, I suggest you to go through LabVIEW Basics and also check help for the available BD Functions to understand better.
Just completing the task without understanding the basics will not help you in any way.
05-03-2023 12:18 PM
I marked this as the solution because it ultimately gave me what I needed.
But is there a way to dictate which direction it searches the spreadsheet? Since the values are organized based on time (FIFO) and the carriers will be used more than once, if I use carrier 48 earlier in the day, then again later. It will only show the first occurrence of the carrier #48. I know with Active-X I can specify which direction to search the data by, but is there a similar way to do this using the example you gave?
05-03-2023 12:55 PM - edited 05-03-2023 12:57 PM
Right off the top of my head I would do something like this:
The For Loop uses Match Regular Expression and returns an array containing the indexes of all the rows that have the same Carrier. As long as they are entered chronologically you can Min/Max the array of indexes and the Max will be the most recent.
05-03-2023 04:53 PM
Just dawned on me that this would do the same thing, the simple equals comparison is faster than Match Regular Expression.