Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64870

Re: Remove unwanted characters from column

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.python
Subject Re: Remove unwanted characters from column
Date 2014-01-27 15:22 +0000
Organization A noiseless patient Spider
Message-ID <lc5tkh$f90$2@dont-email.me> (permalink)
References <8d703876-ba90-492d-a558-a5a9bb8023c7@googlegroups.com>

Show all headers | View raw


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@gmail.com

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Remove unwanted characters from column matt.s.marotta@gmail.com - 2014-01-26 19:49 -0800
  Re:Remove unwanted characters from column Dave Angel <davea@davea.name> - 2014-01-27 00:24 -0500
    Re: Remove unwanted characters from column matt.s.marotta@gmail.com - 2014-01-27 05:32 -0800
      Re: Remove unwanted characters from column Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-27 13:54 +0000
        Re: Remove unwanted characters from column matt.s.marotta@gmail.com - 2014-01-27 06:23 -0800
          Re: Remove unwanted characters from column Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-27 14:34 +0000
          Re: Remove unwanted characters from column Chris Angelico <rosuav@gmail.com> - 2014-01-28 01:57 +1100
            Re: Remove unwanted characters from column matt.s.marotta@gmail.com - 2014-01-27 07:03 -0800
              Re: Remove unwanted characters from column Chris Angelico <rosuav@gmail.com> - 2014-01-28 02:19 +1100
  Re: Remove unwanted characters from column Denis McMahon <denismfmcmahon@gmail.com> - 2014-01-27 15:22 +0000

csiph-web