Python Forum
sorting a strange file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sorting a strange file
#2
I suggest a 3 steps procedure

Step 1: A python program reads the big.txt file line by line and creates a new big file bigggg.txt by replacing each line
Output:
foo/bar/baz spam/eggs ham/bacon
with
Output:
bacon foo/bar/baz spam/eggs ham/bacon| . |
Notice that the primary key has been added in front of each line and the white space between tokens has been normalized to a single space. At the end of the line, the initial blocks of white space have been written, separated by dots and enclosed between pipe characters.

Step 2 Run gnu sort on bigggg.txt, producing sbigggg.txt

Step 3 Read sbigggg.txt line by line and write sbig.txt by the reverse operation on each line.
Reply


Messages In This Thread
sorting a strange file - by Skaperen - Oct-13-2018, 02:15 AM
RE: sorting a strange file - by Gribouillis - Oct-14-2018, 01:59 PM
RE: sorting a strange file - by wavic - Oct-14-2018, 02:13 PM
RE: sorting a strange file - by Gribouillis - Oct-14-2018, 02:28 PM
RE: sorting a strange file - by wavic - Oct-14-2018, 02:54 PM
RE: sorting a strange file - by Gribouillis - Oct-14-2018, 06:04 PM
RE: sorting a strange file - by wavic - Oct-14-2018, 06:24 PM
RE: sorting a strange file - by Larz60+ - Oct-14-2018, 07:56 PM
RE: sorting a strange file - by wavic - Oct-14-2018, 11:05 PM
RE: sorting a strange file - by Skaperen - Oct-15-2018, 02:12 AM
RE: sorting a strange file - by wavic - Oct-15-2018, 05:03 AM
RE: sorting a strange file - by Skaperen - Oct-15-2018, 06:16 AM
RE: sorting a strange file - by wavic - Oct-15-2018, 06:24 AM
RE: sorting a strange file - by Gribouillis - Oct-15-2018, 09:37 AM
RE: sorting a strange file - by Skaperen - Oct-15-2018, 07:31 PM
RE: sorting a strange file - by wavic - Oct-15-2018, 07:52 PM

Forum Jump:

User Panel Messages

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