How to Extract amount from text file

I have text file with number of transection and amount i want to get only last line Credit amount
|D| 1000.11|
|D| 2000.88|
|D| 3000.11|
|C| 6000.11|

I want only 6000.11

Use Read CSV to put it into a datatable. Designate | as the delimiter. To get the second column of the last row:


If you want it as a numeric value (Double) then put a CDbl around it:


The reason for the -1 is that Rows is 0 index, so the first row is 0. That means if you have 4 rows, the last row is index 3. Same for the (1) index…the second column is index 1.

1 Like


if it looks like above then you can try this split




Hi @Anil_Potekar

Use the Regex expressions to extract amount from the given text file. Find the below regex expression.



Hope it helps!!

1 Like

Input in text file or it is in datatable.



Str is the output of read text file …and of stirng type



  1. Use the “Read Text File” activity to read the content of the text file into a string variable, let’s call it textFileContent.
  2. Use the “Matches” activity to extract all matches of the credit amount from textFileContent. Configure it as follows:
  • Input: textFileContent
  • Pattern: \|C\| (\d+\.\d+)\|
  • Result: Create a new variable, let’s call it matches, of type System.Text.RegularExpressions.MatchCollection.
  1. Use the “Assign” activity to assign the last match’s value to a string variable, let’s call it creditAmountString. Set the value as follows:
  • matches(matches.Count - 1).Groups(1).Value
  1. Use the “Convert.ToDouble” activity to convert creditAmountString to a double variable. Let’s call the double variable creditAmount.
  2. Now, the creditAmount variable will contain the credit amount from the last line of the text file
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.