Python Forum
How best to format text in a simple text file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How best to format text in a simple text file?
#1
I have text documents. They consist of 1 sentence on each line, maybe 35 lines. I want to add the correct sentence from the answers text file under each line and give the whole thing a bit of formatting.

I think pprint presents text neatly. Can it do simple formatting and write to a text file?

I basically want an indent and some space at the top and/or bottom and some line spacing.

When I batch print the text files I have from a bash terminal, the text is left, no margin, top, no margin.

I can think of ways to add spaces left and above, but I think there is probably a module to handle this.

What's the best way to do this?

How would you do it?

Maybe I should use the docx module? I'd rather stick with simple text files if I can.
Reply


Messages In This Thread
How best to format text in a simple text file? - by Pedroski55 - Jun-13-2019, 03:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 1,051 Apr-24-2024, 05:47 AM
Last Post: Bronjer
Brick Number stored as text with openpyxl CAD79 2 508 Apr-17-2024, 10:17 AM
Last Post: CAD79
  Sending a text from Python sawtooth500 2 226 Apr-14-2024, 01:56 PM
Last Post: sawtooth500
  very newbie problem on text file zapad 2 270 Apr-12-2024, 06:50 PM
Last Post: zapad
  help with scrolling text on RGB Matrix Foutsy 3 336 Apr-09-2024, 09:00 PM
Last Post: deanhystad
  Text parsing Arik 5 453 Mar-11-2024, 03:30 PM
Last Post: Gribouillis
  replace text in a txt cartonics 19 2,380 Jan-30-2024, 06:58 AM
Last Post: Athi
  Text conversion to lowercase is not working ineuw 3 508 Jan-16-2024, 02:42 AM
Last Post: ineuw
  Script that alternates between 2 text messages DiscoMatic 1 548 Dec-12-2023, 03:02 PM
Last Post: buran
  Decryption not working if key has same symbol like text Paragoon2 0 332 Nov-11-2023, 09:32 PM
Last Post: Paragoon2

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020