I converted a pdf to txt. It returned the file where the whole text is written in one line. In order to work with the file i need to add 2 new lines before a number and one after it. (btw. i am using python 3.6)
F.e.:
Input:
Here is some text. It is written in one lines. 12.13. Here is some more text. 2.12.14. Here is even more text.
Output(i wish to have):
Here is omse text. It is written in one lines.
12.13.
Here is some more text.
2.12.14.
Here is even more text.
This is my code. The code runs , but unfortunatly reautrns an empty page. I would be glad about some editing advice.
F.e.:
Input:
Here is some text. It is written in one lines. 12.13. Here is some more text. 2.12.14. Here is even more text.
Output(i wish to have):
Here is omse text. It is written in one lines.
12.13.
Here is some more text.
2.12.14.
Here is even more text.
This is my code. The code runs , but unfortunatly reautrns an empty page. I would be glad about some editing advice.
in_file2 = 'work1-T1.txt' out_file2 = 'work2-T1.txt' start_rx = re.compile('|'.join( ['\d\d\.\d\d\.', '^\d\.\d\d\.\d\d'])) with open(in_file2,'r', encoding='utf-8') as fin2, open(out_file2, 'w', encoding='utf-8') as fout2: text_list = fin2.read().split() for line in in_file2: start = True if re.match(start_rx, line): line = line.replace(start_rx, '\n\n' + start_rx + '\n') if line == True: fout2.write(line)