CSV ignores lineterminator

Discussion in 'Python' started by Jeffrey Barish, Apr 5, 2004.

  1. With

    input_data = ['word1\tword2;word3\tword4;',
    'word5\tword6;word7\tword8;']

    and

    delimiter = '\t'
    lineterminator = ';'

    shouldn't csv.reader(input_data, dialect='mydialect') return

    ['word1', 'word2']

    as the first row? I find that it doesn't matter how I set
    lineterminator, csv always terminates at the end of the line returned
    by the iterable object passed as its first argument (input_data, in
    this case). I must be missing something basic here.

    I may be confused about the interaction between what iterable object
    defines as the next row and what csv.reader defines as the next row.
    The documentation for csv says that the line returned by csv.reader can
    span multiple input lines. I assume that this would happen if the
    lineterminator is defined as something other than \n, in which case
    csv.reader would keep pulling in lines until it finds the
    lineterminator. This is not the behavior I am observing.

    I'm using Python 2.3 on Linux 2.4.23.
    --
    Jeffrey Barish
     
    Jeffrey Barish, Apr 5, 2004
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Teuvo Eloranta
    Replies:
    1
    Views:
    544
    Skip Montanaro
    Feb 5, 2004
  2. Michal Mikolajczyk
    Replies:
    0
    Views:
    923
    Michal Mikolajczyk
    Feb 13, 2004
  3. Tintin92
    Replies:
    1
    Views:
    2,135
    Andrew Thompson
    Feb 14, 2007
  4. jliu66
    Replies:
    0
    Views:
    758
    jliu66
    Oct 19, 2007
  5. sso
    Replies:
    20
    Views:
    3,193
    Martin Gregorie
    Apr 26, 2009
  6. Tim
    Replies:
    1
    Views:
    475
    Peter Otten
    Jul 5, 2010
  7. Li Chen
    Replies:
    18
    Views:
    1,008
    Azmi Farih
    Mar 23, 2010
  8. Sacha Rook

    csv read clean up and write out to csv

    Sacha Rook, Nov 2, 2012, in forum: Python
    Replies:
    2
    Views:
    456
    Hans Mulder
    Nov 2, 2012
Loading...