Python Forum
looking 4 py code: line up columns
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
looking 4 py code: line up columns
#9
(Jan-07-2017, 04:25 AM)ichabod801 Wrote: I've done this before, I just can't remember where. It's not that hard. Loop through the columns, determining the maximum width of the string representations. Construct a format string (with {}'s) using the width information plus 1 or 2 spaces for a gutter. Loop through the rows, passing the row to the format method with * notation. Join the resulting strings with '\n'. You just have the added wrinkle of detecting numeric columns and putting that into the format specification.

one thing i was looking for was to see how intermixing of column types was handled.  if left justified column is to the the left of a right justified column it leave open the option to squeeze them tighter.  would you (dare to) do that?  that's code i'd like to see.

FYI, i did this decades ago in 370 assembler ... with the justification mix.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
looking 4 py code: line up columns - by Skaperen - Jan-06-2017, 06:25 AM
RE: looking 4 py code: line up columns - by Skaperen - Jan-09-2017, 05:15 AM
RE: looking 4 py code: line up columns - by wavic - Jan-07-2017, 08:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  wanted: regex or code to find valide def statements in a line Skaperen 13 5,564 Mar-20-2020, 11:54 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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