PrincessPeach2091
PrincessPeach2091

Reputation: 159

Transform Word Document data into showing the "new line" separator within the text

So I'm trying to get a standard word document into a csv format which includes the "\n" new line indicator or "\n" within the text itself. I'll be using this data so I can fine-tune a natural language model I'm working on.

So for example,

Hey there,

My name is Jim and I'm excited to begin working for Microsoft. I believe my job history fits perfectly within the Microsoft Culture.

Thanks!
Jim

Would become

Hey there,\n My name is Jim and I'm excited to begin working for Microsoft. I believe my job history fits perfectly within the Micorosoft Culture. \nThanks! \nJim

I tried using Notepad++ to show the line breaks, which it did, but it was in a weird format and not actually displaying the text but just visually showing where the line breaks were.

Upvotes: 0

Views: 54

Answers (1)

JayPeerachai
JayPeerachai

Reputation: 3842

Use repr() to show the string representation of the string.

e.g.

text = """Hey there,

My name is Jim and I'm excited to begin working for Microsoft. I believe my job history fits perfectly within the Microsoft Culture.

Thanks!
Jim"""

new_text = repr(text)

Output:

print(new_text)
> "Hey there,\n\nMy name is Jim and I'm excited to begin working for Microsoft. I believe my job history fits perfectly within the Microsoft Culture.\n\nThanks!\nJim"

Upvotes: 1

Related Questions