.I’m trying to achieve something with Python where it can intelligently be able to transform an input and apply string format rules for a repeatable output, sort of a like a smart ETL function, if you will. Case in point, I will be receiving numerical data from geographically disperse clients and that data needs to be transformed into a repeatable format so it can be consumed by our legacy financial engine.
For example, I might receive numerical data such as:
input = 123,456,789.4533
This input data needs to be reformatted to an output of 26 digits, depicted as (17)(9), where the first 17 digits are the values of the input value left of the decimal point, zero padded on the left and the 9 would be all the input values to the right of the decimal point, again, zero padded on the right. So, if we were to transform it, it would look like:
output = 00000000123456789453300000
Now, there might be times where the input data would look like this:
123456789.4533
123.456.789,4533 (european currency)
What would be the best way to perform this in Python?
You can do it with regular expressions
prints:
00000000123456789453300000
00000000123456789453300000
00000000123456789453300000