Extract values using Substring

studio
variable

#1

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

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


#3

@savithrin

Check attached File

SubstringRemove.zip (1.9 KB)


#4

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:


#5

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


#6

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:


#7

Can you tell me how to to that :roll_eyes:


#8

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


#9

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.


#10

Substring sample.xaml (8.2 KB)


String manipulation - read all words between two hashes ##
#11

thanks all now it works perfectly :smiley:


#12

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


#13

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:


#14

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?


#15

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


#17

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.


#18

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.


#19

Hi @lakshman

Try this sample

Main.xaml (6.7 KB)

Have a text file with you available text and try this

Thanks,
Prankur


#20

@prankurjoshi,

Thanks for quick reply. Its working fine.


#21

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.