Python Forum
Split Characters As Lines in File
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split Characters As Lines in File
#3
There is built-in module textwrap:

>>> import textwrap
>>> s = '1010100101010110000000000001111111111'
>>> print('\n'.join(textwrap.wrap(s, width=10)))
1010100101
0101100000
0000000111
1111111
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Split Characters As Lines in File - by quest_ - Dec-27-2020, 07:16 PM
RE: Split Characters As Lines in File - by perfringo - Dec-28-2020, 04:48 AM
RE: Split Characters As Lines in File - by quest_ - Dec-28-2020, 09:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] how to delete the 10 first lines of an ascii file paul18fr 7 2,167 Aug-07-2024, 08:18 PM
Last Post: Gribouillis
  using last 2 characters of a file name to identify it CAD79 5 2,091 Jul-12-2024, 02:09 PM
Last Post: deanhystad
  doing string split with 2 or more split characters Skaperen 22 6,924 Aug-13-2023, 01:57 AM
Last Post: Skaperen
  How to "tee" (=split) output to screen and into file? pstein 6 4,530 Jun-24-2023, 08:00 AM
Last Post: Gribouillis
  Split pdf in pypdf based upon file regex standenman 1 4,848 Feb-03-2023, 12:01 PM
Last Post: SpongeB0B
  counting lines in split data Skaperen 6 3,248 Oct-07-2022, 07:09 PM
Last Post: Skaperen
  Delete multiple lines from txt file Lky 6 4,279 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  failing to print not matched lines from second file tester_V 14 9,480 Apr-05-2022, 11:56 AM
Last Post: codinglearner
  Extracting Specific Lines from text file based on content. jokerfmj 8 6,022 Mar-28-2022, 03:38 PM
Last Post: snippsat
  How to split file by same values from column from imported CSV file? Paqqno 5 6,139 Mar-24-2022, 05:25 PM
Last Post: Paqqno

Forum Jump:

User Panel Messages

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