python replace newline

Solutions on MaxInterview for python replace newline by the best coders in the world

showing results for - "python replace newline"
Mattia
23 Apr 2019
1without_line_breaks = a_string.replace("\n", " ")
Lincoln
24 Jun 2019
1from tika import parser
2
3filename = 'myfile.pdf'
4
5# Parse the PDF
6parsedPDF = parser.from_file(filename)
7
8# Extract the text content from the parsed PDF
9pdf = parsedPDF["content"]
10
11# Convert double newlines into single newlines
12pdf = pdf.replace('\n\n', '\n')
13
14#####################################
15# Do something with the PDF
16#####################################
17print (pdf)
18