Currently I am bashing my head at a task that seems to be way too complicated for a beginner in python as myself. I'd be really grateful if you could give me a hand in this. I am trying to replace a comma with a dot. I want it done only for a particular element in a SQL script (the bold value):
Insert into SEC_DATA (HEADER_ID,TIMESTMP,BOMLABEL,TI_TO_EX,HOLD_TI,STRIKE,STRIKE_FORM,SDVALUE,VALUE1,VALUE2) values ('Swaption-Volatilitдten','02/03/2016 00:00:00','DD/MM/YYYY HH24:MI:SS'),'BID','5400','10800','0','D','**0,595**','0','0');
Sooo, I decided to use regular expressions and did the following thing:
x = "Insert into SEC_DATA (HEADER_ID,TIMESTMP,BOMLABEL,TI_TO_EX,HOLD_TI,STRIKE,STRIKE_FORM,SDVALUE,VALUE1,VALUE2)
values ('Swaption-Volatilitдten','02/03/2016 00:00:00','DD/MM/YYYY HH24:MI:SS'),'BID','5400','10800','0','D','0,595','0','0');"
var = re.sub(r"(\d),(\d)", r"$1.$2", x)
I am expecting the $1 and $2 to keep the group unchanged, for I only want to turn the comma into a dot. The numbers around the comma are only to make sure that this is the right comma.
However, whatever I do it always results in a change of the surrounding numbers, too:
...('Swaption-Volatilitдten',to_date('02/03/2016 00:00:00','DD/MM/YYYY HH24:MI:SS'),'BID','5400','10800','0','D','**$1.$2**95','0','0');
How can I fix that?
Thanks in advance.
nesh