Read Invoice values from Text file

Hi @ClaytonM,

I have text in this format.
Source Id
123455
Destination
1234456.

How can i extract data (123455) which is in next line after the keyword (Source Id).I didn’t get your previous explanation.Can you eloborate on that?

Thanks in advance.

@sreekanth, Let me try explaining you what @ClaytonM has told,

Say string Str contains the input

Source Id
123455
Destination
1234456

If you use only the following,
Str.Split({“Source Id"},System.StringSplitOptions.RemoveEmptyEntries)(1) it will give output as,

123455
Destination
1234456

Because it splits based on the word Source Id where first index i.e 0th index will have a empty/null value and 1st index will have our output mentioned above(italicized).

Again if you make the following operation in that output,
.Split(System.Environment.Newline(0))(0)
It will return 123455

Because splitting based on newline will give 3 elements while accessing the first one 0th index gives our output(italicized).

Note thus Clayton has used the whole code to get it in a shot.

Regards,
Dominic :slight_smile:

1 Like


@Dominic
My string input is below:

Business

Source ID (Name)

1323245

Destination ID (Name)

123456

Document Type

wdfag

Format

asdsdfds

@sreekanth,
May I know what are you getting ?

Regards,
Dominic :slight_smile:

image@Dominic

I have changed datas to array of strings.I am getting the above error

@sreekanth, as we get are accessing only the first index which is nothing but a string then you have to change the type from string array to string. And in error it was clearly mentioned.

Regards,
Dominic :slight_smile:

When I,m changing 1 dimensional array to string,I,m getting this error.@Dominic

@sreekanth, Your Input has Source ID (Name) in it instead of Source Id . Did you make the changes accordingly?

Regards,
Dominic :slight_smile:

Hi @sreekanth,

Use Matchs activity

In properties

  • Input-> Str (your input)
  • Pattern-> ((?<=Source Id).*(?=Destination))
  • Output-> IEnumResult (variable data type IEnumerable<Match>)

Source Id output → IEnumResult(0).ToString()

Regards,
Arivu

Hi @sreekanth

Check out the posts here on using Matches pattern to pull out all the values under certain text.

Regards.

Hi @SHAISTA,
Use screen scraping and assing values to variables.Then build a datatable and add data row using variables.Then you can write the datatable to excel .If you have multiple pdf’s use open application activity and pass your pdf reader.exe in it.

Thanks,
sreekanth.k

I want to know if for the first pdf the data gets written in the 3rd row . Then what should be done so that the data of 2nd pdf comes in the 4th row.

Use Add datarow row in Datatable,It automatically adds data in correct order.
@SHAISTA

I am using that but i think it is over-writing on the values of 1st pdf.

Did you build a datatable outside forloop.

Yes, i did.

Use Add datarow inside forloop,then you should be getting correct data.It will not overwrite existing data

Use open application,Pass use default pdfreader.exe.Use for each file in folder and iterate through the files and pass that arguement in open application,then you will get different values.Your problem is everytime you are accesing the same pdf.

HI @vvaidya

I need to extract some specific data from text file but In that text file more than one elector name,fathers name, age is there how to read all values can you please provide any sample xaml