How can I transform a value after it was extracted?

214 Views Asked by At

I am using Portia to extract info from a page. However, one of the values extracted is not in a format that I can use.

More specifically, I want to extract a numeric value which uses a dot instead of a comma to denote thousands e.g. "1.000" instead of "1,000".

Is it possible to extract and then transform with Portia? I can set a regex to extract numbers but is it possible to replace them too?

What I'm doing now is that I export the data to csv and then use sed to replace the numbers in question.

Thanks

1

There are 1 best solutions below

2
Thomas Strub On

Check: How do I use Python to convert a string to a number if it has commas in it as thousands separators?

import locale
locale.setlocale( locale.LC_ALL, 'de_DE.UTF-8' )
locale.atoi('1.000')
# 1000

Basically it's string to number with the correct format mask