Need to find index of array value in text file

hi team,
I have a query like I have data in the text file so I need to get the index of a particular value
actually, i am using this condition but getting the value is 0

stringp array=array.indexof(Variable,“Value”)+1

Varaible =item.split(environment.newline.toarray)

I am using this condition but getting a 0 value

Hi @Anil_Rajavarapu ,

Could you check or provide us with the Data present in the variable ? Also we assume the Split assignment is done first and then the IndexOf was performed.

actual the condition first I am using splitting text file data using this condition

the array of string Varaible like

SIngleLC=item.split(environment.newline.toarray)

next based on this I am checking the index of particular value

stringp array=array.indexof(SingleLC,“Value”)+1

but i am getting 0 value

@Anil_Rajavarapu ,

This does seem correct but did you have the chance to check the Splitting happening ? Can you check the values of SingleLC after the Split operation ? You could do this by Setting a Breakpoint and checking the value with Debug.

yes SingleLC is working i have checked in debug but the issue is in finding index only or else is there any alternate condition

fo example in my text file data will be like this

30A:address
some address
some address
some address
40B:Name
Some Name

so that in that data i need to check the some address and some name values based on index only

@Anil_Rajavarapu ,

Next question would be are you checking for an Exact match or are you checking if the value that you want to find is present in the list/array item with some other values also ?

This is incorrect syntax. Try:

item.split(environment.newline)

Split automatically returns an array. Your original syntax is converting environment.newline to an array and passing it to Split, which makes no sense.

my text file data like this
30A:address
some address
some address
some address
40B:Name
Some Name
47A:Currency
Amount :-444

like this
i am checking the sub-values based on num indexes like 40B or 47A if it matched go to sub-values and check values or need to remove

@postwick in correct means i am looping the values one by one

if i remove .toarray getting error like option strict allows to string to integer

That’s not where you do the loop.

Then you have some other issue. environment.newline.toarray is definitely incorrect.

What is the datatype of item? In your For Each, did you change the TypeArgument to string? It defaults to Int32.

Post screenshots of your code, your activities, and their properties so we can help you.

Actually the data formate come in text file like this

  1. 30A:address
    some address
    some address
    some address
    40B: Name
    Some Name
    47A:Currency
    Amount:-444
  2. 30A:address
    some address
    some address
    some address
    40B: Name
    Some Name
    47A:Currency
    Amount:-525.69
  3. 30A:address
                 some address
                  some address
                  some address
    
    40B: Name
    Some Name
    47A:Currency
    Amount:-666.00
    so above data i am looping one by one and if in name sub value is matched in second data row i need to copy entire 2nd data and paste into word file and update the some address values and some name values

yes i have changed type argument to sting

In that case I would start off by using Regex.Split on the 1. 2. 3. etc to split it into individual records, and loop through that result.

Then for each of those, you can then use Regex to extract the address and name.

the data is not only 3 records it will come in around 300 one by one we need to check

This splits them up into individual records:

image

image

i will check this logic and let you know

Then as you’re looping through each item, you can use this expression to, for example, get the text after "40B: "

Regex.Match(currentItem,"(?<=40B: ).*").ToString.Trim