Extract values using Substring

Hi all,

I am a beginner to RPA. I want to Extract some values using Substring.

ID: 001
Brand: Shirt
Size: S
Color: Blue

I want to get only below values separately. >>
001
Shirt
S
Blue

Can anyone help me ??
Thanks in Advance :slight_smile:

2 Likes

Hey @savithrin

Refer below thread and u will be able to get some idea about it.

if still will face problem, Let us know.

Regards…!!
Aksh

5 Likes

@savithrin

Check attached File

SubstringRemove.zip (1.9 KB)

5 Likes

Hi ,
Thanks for the help. But now i am facing another problem.
In my case I am getting above mentioned data from a PDF using read PDF text. variable name = pdf1.

test1_id = Split(pdf1.ToString , “:”)
output = test1_id(test1_id.Length-4)

When I print the output variable, it shows the value as this.
image

Can any one help me :roll_eyes:

1 Like

you have to split first your string with Newline then you will be able to use what you have done.

hi,

The thing is am getting those data from a pdf. So I think I cant use your method. Anyway thanks for the great help :slight_smile:

Can you tell me how to to that :roll_eyes:

Hi @savithrin,

StrValue=" ID: 001
Brand: Shirt
Size: S
Color: Blue"

ArrNewline-> string
ArrNewline=StrValue.Split(Environment.NewLine.ToArray, StringSplitOptions.RemoveEmptyEntries)

Use for each activity

Arrvalue=Item.Split(":"c)
Push the value into Dictionary
Key=arrValue(0) and Value=arrValue(1)

image

dictPromoData(“Brand”) → you will get the value as “Shirt”
Refer this post

Regards,
Arivu

8 Likes

Nice example.
Don’t forget to add .Trim calls or change Split(":"c) to .Split(": ") (without c qualifier, as then we’re splitting by actual string, not char) , otherwise you’ll have leftover whitespace in the values (and possibly keys as well, depending on original string).

PS. You’re adding a lot of code to the forum, it would look better and be safer (and easier to copy) if you’ll put them in code tags or backticks.

3 Likes

Substring sample.xaml (8.2 KB)

5 Likes

thanks all now it works perfectly :smiley:

Hi everyone.

I am trying to extract data from a text file. I am using substring while looping through each line in text file.

Now the problem is , in text file. Under comments, some lines has data in comments field and some doesnot. Its failing if the comments is blank.

Do you guys have any approach , how to handle such exceptions in substring

would you mind to give us some text example?

If you are reading a CSV with some quotes:

Text Example:
“123”,343,“pppp”

My preffered way its just erase all quotes with a line.Replace(“”",string.empty)

If this is not your case, give us an example :slight_smile:

1 Like

sAMPLE DATA.zip (859 Bytes)

I need to convert this text file into excel. You can see that in third row, comments column is blank. I used this approach to use substring to read each column value. But its failing for comments column. Any another approach?

hi im new at uipath
i just want to ask on how to limit String character .

i want to have only 15 character . Please help

Hi Indra

So I looked on your variables and I noticed that you set default values which are the given data to be manipulated, my question is what if it’s a list where by the ID, Brand, Size and Color are going to change, how are you going to do it.

Hi All,

I want to find the GST No. from below string. Can any one help me in this.

Input :
We have debited/credited your account as below :
Account Details Debit/Credit Amount & Currency Amount in Words
BO-10205-80304-USD Credit USD 58,956.88 Fifty Eight Thousand Nine Hundred and Fifty Six
US DOLLAR and Eighty Eight Cents
10008447173 Debit INR 354.00 Three Hundred and Fifty Four Rupees
Charge and Tax details :
Description Charge Amount IGST SGST CGST
Commission INR 300.00 INR 54.00 INR 0.00 INR 0.00
TOTAL INR 300.00 INR 54.00 INR 0.00 INR 0.00GRAND TOTAL of Charges & Taxes : INR 354.00 GSTIN :
34AADCS810
4P2Z1
FIRC Utilisation Details :
FIRC No FIRC Date Amount Currency

I want output like this: GSTIN : 34AADCS8104P2Z1

Regards,
Lakshman Ganta.

1 Like

Hi @lakshman

Try this sample

Main.xaml (6.7 KB)

Have a text file with you available text and try this

Thanks,
Prankur

3 Likes

@PrankurJoshi,

Thanks for quick reply. Its working fine.

Hi All,

i am using read PDF text activity to read the file and giving output as text. Below is that text.

We have debited/credited your account as below :
Account Details Debit/Credit Amount & Currency Amount in Words
BO-10205-80304-USD Credit USD 77,891.22 Seventy Seven Thousand Eight Hundred and
Ninety One US DOLLAR and Twenty Two Cents
10008447173 Debit INR 354.00 Three Hundred and Fifty Four Rupees
Charge and Tax details :
Description Charge Amount IGST SGST CGST
Commission INR 300.00 INR 54.00 INR 0.00 INR 0.00
TOTAL INR 300.00 INR 54.00 INR 0.00 INR 0.00
GRAND TOTAL of Charges & Taxes : INR 354.00 GSTIN :
34AADCS810
4P2Z1

I want to read 2 rows data from first table and sometimes here it may be 1 or 3 rows also. How to fetch these details. can anyone help me in this.

Regards,
Lakshman Ganta.

1 Like