BigAl

Arraysearch column 0, return value from column 1

7 posts in this topic

#1 ·  Posted

I have a CSV file which i am putting into a 2D array, for the purpose of this we'll say the 2 columns are "ID" and "NAME"

What I need todo is search the array for a variable (a variable I read from an ini file on the local machine) which is in column 0 but i want to return the value in string in column 1 for that row, ie: 

ID, NAME

01, AAAA

02, BBBB

03, CCCC

 

So if i search in the array for "02" i want it to return the string "BBBB" so i can use this as a variable later on.

I'm using the CSVSplit.au3 from czardas to get my csv into a 2D array which is working perfectly.

I have tried using the _ArraySearch in Combo with _ArrayToString but the output i'm getting is "02, BBBB" instead of just "BBBB" from my example above.

Any help on how todo this would be greatly appreciated, and apologies if this has already been covered, i did look though the forum first but couldn't find a solution. 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Why not use the INI* functions for this if it's an .ini file?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thanks for your reply.

The ini file on the local machine only has the "ID" in it, not the name, so i have a CSV which matches the ID to the name which i will include within my final exe, so i need to reference the ID pulled out of the ini file against my csv to get the correct name. 

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

In that case, don't use _ArrayToString, just reference the array's [1] element to get just the second column's text.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#6 ·  Posted

@subz I could have posted working code, but chose to point the user in the direction they needed so they could learn to use AutoIt.

I'd refer you to my signature, specifically the second line in red as to why.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#7 ·  Posted

@BrewManNH Actually read your previous post incorrectly, I thought you had written $aArray[1] so was going to just clarify that it was $aArray[_ArraySearch][1] but then thought it wouldn't make sense so just wrote out the function for clarity.

Apologies for that.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now