Using Python, I have the following lines:
['taxes............................. .7 21.4 (6.2)','regulatory and other matters..................$ 39.9 61.5 41.1','Producer contract reformation cost recoveries............................ DASH 26.3 28.3']
I need to replace each of the points with a space, but not periods in numbers. The result should look like this:
['taxes .7 21.4 (6.2)','regulatory and other matters $ 39.9 61.5 41.1','Producer contract reformation cost recoveries DASH 26.3 28.3']
I tried the following:
dots=re.compile('(\.{2,})(\s*?[\d\(\$]|\s*?DASH|\s*.)')
newlist=[]
for each in list:
newline=dots.sub(r'\2'.replace('.',' '),each)
newdoc.append(newline)
But this code does not save a space. Thanks!
source
share