I have columnar data in which a column of data ranges widely in width. I would like to display this data in a monospace font, for easy viewing while additionally retaining the capabilities of parsing that data with common csv handlers.
I am willing to accept that a strip/trim operations may need to be done by the parsing lib and I am not worried about leading/trailing white space being preserved.
How can I write a csv with fixed width data columns? Is this possible with the csv
module?
In Open/Libre Office terms, this is called "Fixed column width" in the Export Text File options.
Example
data = [
('Brown Fox Jumps Over', 'Lorem ipsum',),
('The Lazy', 'dolor sit amet,',),
('Dog', 'consectetur adipiscing elit.',),
]
Desired output
"Header 1 ", "Header 2 ",
"Brown Fox Jumps Over", "Lorem ipsum ",
"The Lazy ", "dolor sit amet, ",
"Dog ", "consectetur adipiscing elit.",
Chiefly I'm looking for a tool to scan a dataset for its widest values and format then entire column to that width for all columns because writing one myself inline feels inappropriate.