Python re.sub newline multiline dotall
I have this CSV with the following lines written on it (note the new line / n):
"<a>https://google.com</a>",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,,Dirección
I am trying to remove all these commas and putting the address in one line up. So in Python I use this:
with open('Reutput.csv') as e, open('Put.csv', 'w') as ee:
text = e.read()
text = str(text)
re.compile('<a/>*D', re.MULTILINE|re.DOTALL)
replace = re.sub('<a/>*D','<a/>",D',text) #arreglar comas entre campos
replace = str(replace)
ee.write(replace)
f.close()
As far as I know, re.multiline and re.dotall are needed to fulfill / n needs. I use re.compile because this is the only way to add them, but obviously compilation is not needed here.
How can I finish using this text?
"<a>https://google.com</a>",Dirección
, . , re.sub. MULTILINE, ^ $, .
, , , .
. re.sub , replace = str(replace) .
:
import re
with open('Reutput.csv') as e:
text = e.read()
text = str(text)
s = re.compile('</a>".*D',re.DOTALL)
replace = re.sub(s, '</a>"D',text) #arreglar comas entre campos
print(replace)
re.sub ,
re.sub('</a>".*D', '</a>"D', text, flags=re.DOTALL)
, , , , ,
replace = ''.join((c for c in text if c not in ',\n'))
re.compile, Regular Expression, . . * close html. re.MULTILINE (^ $), .
regex = re.compile('</a>.*D',re.DOTALL)
replace = regex.sub('</a>",D',text)
. , .
, .
replace = re.sub('"(,|\n)*D','",D',text)