Split fonction

hello guys,
I want to use split fonction get the (name and the first name,…) from file below
can u please help me ??
image

@sam35
You can read the PDF text using either Read PDF Text or Read PDF With OCR. That will save all of the text to a variable, let’s call it pdfText. Then you can split that by the newline character to get each line on its own. pdfLines = pdfText.Split(Environment.NewLine.ToCharArray,StringSplitOptions.RemoveEmptyEntries) where pdfLines is an array of strings.

Now pdfLines(0) is equal to “NOM BENEFICIARE : CARON” and pdfLines(1) is equal to “PRENOM BENEFICIARE : Danielle”. To get just the name portion you can split by :.

pdfLines(0).Split(":".ToCharArray).Last.Trim gives “CARON”
pdfLines(1).Split(":".ToCharArray).Last.Trim gives “Danielle”

This splits the line by the colon, takes the last element, and removes extra whitespace.

2 Likes

@DanielMitchell, tank you, but it is not a PDF file, it is a web page, and i get it for the last part. but i couldn’t split the full text into Arry of strings

1 Like

Fine
we can use GetText activity and get the output in a string variable named intext
–now use a assign activity like this
outtext = intext.Split(Environment.Newline.ToArray())
where outtext is a variable of type string array
–now in the for each loop activity pass the above variable outtext as input and change the type argument property of the for each loop as string
–inside use a if condition like this
item.ToString.Contains(“NOM BENEFICIARE”)
if the above condition passes it will go to THEN part we can use a write line activity like this
“First name is : " + Split(item.ToString,”:").ToString.Trim
or if the above condition fails it will go to ELSE part where we can mention another if condition like this
item.ToString.Contains(“PRENOM BENEFICIARE”)
and if the above condition passes it will go to THEN part where we can mention with a write line activity like
“Last name is : " + Split(item.ToString,”:").ToString.Trim

simple isn’t it
hope this would help you
Kindly try this and let know for any queries or clarification
Cheers @sam35

@sam35
You are able to get the full text, though? What happens if you try to split the full text by lines?

small change a typo mistake
“First name is : " + Split(item.ToString,”:")(1).ToString.Trim

and for this as well
“Last name is : " + Split(item.ToString,”:")(1).ToString.Trim

Cheers @sam35

Thanks for both of you @Palaniyappan and @DanielMitchell.

@Palaniyappan it isn’t working, i dont why i don’t have an output :frowning:
TEst2.xaml (10.3 KB)

@sam35
I can’t see your url in the xaml that you attached. Could you scrape the body text, write it to a text file, and then attach that? That should be enough for me to help you.

1 Like
Formulaire en ligne 


    NOM BENEFICIAIRE    : HERLICOVIEZ
    PRENOM BENEFICIAIRE    : Félix
    DATE NAISSANCE BENEFICIAIRE    : 19980829
    PAYS DE SOINS    : FR
    TYPE DE SOINS    : Ostéopathie
    NUMERO INSEE    : 1980875214410
    NOIDE    : 0108749783
    NUMERO ADELI PS    : 710001660
    DATE DES SOINS    : 01012019
    MONTANT DES SOINS    : 140.00

Thanks @DanielMitchell please find below the extrat data

@sam35 Try this out
TEst2.xaml (7.0 KB)

1 Like

It works i am too happy, thanks for both of you, @DanielMitchell @Palaniyappan
Cheers my friends

2 Likes

Great
Cheers @sam35