#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    11
    Rep Power
    0

    Text manipulation


    Hi ,
    i am new in python enviromnet and i wonder if there exist any
    ' high level ' command to find columns separated by blank delimeters in an text document read by python, like it exists in awk in Unix for example, except the old-fashioned and low level use of 'for' command to determine that.

    thanks in advance for any help,
    Nikos
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Python does not do it automatically like awk does, but you can do it yourself using the string split() method:

    Code:
    >>> s = "  a string with spaces  in it...   "
    >>> s.split()
    ['a', 'string', 'with', 'spaces', 'in', 'it...']
    >>>
    Dave - The Developers' Coach

IMN logo majestic logo threadwatch logo seochat tools logo