Remove unwanted characters from column

Denis McMahon denismfmcmahon at gmail.com
Mon Jan 27 10:22:57 EST 2014


On Sun, 26 Jan 2014 19:49:01 -0800, matt.s.marotta wrote:

> School assignment is to create a tab separated output with the original
> given addresses in one column and then the addresses split into other
> columns (ex, columns for city, postal code, street suffix).

If you're trying to create fixed width output from variable width fields, 
format specifiers may be better to use than tabs.

The problem with tabs is that columns end up misaligned when the data 
fields in a column contain a mixture of items of less length than the tab 
spacing and items of greater length than the tab spacing, unless you can 
work out the tab spacing and adjust accordingly.

For example, my code which uses the re module to separate the various 
record components and a format specifier to print the text and html 
versions (and csvwriter for the csv) them creates the outputs seen here:

http://www.sined.co.uk/tmp/farms.txt
http://www.sined.co.uk/tmp/farms.csv
http://www.sined.co.uk/tmp/farms.htm

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list