Jump to content

Recommended Posts

Posted

Hi Guys,

I have two arrays

$array1 and $array2 which contains strings taken from seperate columns from excel sheets. I wasn't able to compare these strings. i used both StringCompare but they turned out to be negative even if the words are same. I even used StringStripWS to take away the white spaces . It was of no use, please give me some ideas.

thanks

Arvinth

Posted

Show some code/snippet how you are doing the compare and what the content of the arrays is.

Jos

********************88getting values from excel in array *******************************************88

for $j = 1 To ($row - 1)

$marry=_ExcelReadCell($oWorkbook,$j)

_arrayinsert($array,$j-1,$marry)

$array[$j-1] = StringTrimRight($array[$j-1], 1)

Next

****************************8getting values for another array *******************************************

### Since the column have interleaved spaces i have few extra conditions

func arjun($obook)

$r=3

while 1

$rowvar = _ExcelReadCell($obook,$r,4)

;MsgBox(0,"Values",$rowvar)

if $rowvar = "" then

$r+=1

;MsgBox(0,"Values","i am here")

$n+=1

if $n > 1 then

ExitLoop

EndIf

Else

;MsgBox(0,"Values",$rowvar)

;MsgBox(0,"Vale of m",$m)

_arrayinsert($array1,$m,$rowvar)

$r+=1

$m+=1

;ConsoleWrite($array1[$m])

$n=0

Endif

WEnd

for $k=0 to ($m)

ConsoleWrite($array1[$k])

Next

EndFunc

****************************************************************************************************

**********************************

Both arrays have required information, but the array has the strings stored without any gap, whereas above one have one white space before and after the word

i even used StringStripWS to strip the second array ie array1 just above this. but ultimately the space remain in array1.

****************************************************************************************************

**********************************

************** for matching ************************************************

for $j=0 to ($row-2)

for $k=0 to $m

if ($array[$j] == $array1[$k]) Then

_ArrayAdd($array2,$array1[$k])

EndIf

Next

Next

******************************************************************************8

i may not be clear just replay me if you are not clear

Posted

Have you listed the exact content of both arrays to see what they contain and why there is no match ?

yes i console wrote them and

for example if

array1 contains an element "ssssssssss545454"

array2 contains same element " sssssssssssss545454 "

Posted

Do you mean that the s'es are spaces?

If so, you could strip all spaces when adding the cell content eg:

_arrayinsert($array1,$m,StringStripWS($rowvar,3))
still no use
Posted

yes i console wrote them and

for example if

array1 contains an element "ssssssssss545454"

array2 contains same element " sssssssssssss545454 "

array1 contains an element...... "ssssssssss545454"

array2 contains same element " sssssssssssss545454 "

You mentioned array2 contains the same element.

If you compare the above 2 strings they are not the same. Too many s's in array2.

  • 2 weeks later...
Posted

I Used StringSplit function to split the string and then inserted them again using _StringInsert function to get those blank spaces out. It was cumersome but it worked out thank you guys for your help

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...