strange problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ken

    #1

    strange problem

    This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
    at EOF I get around 10,000 less lines. Any ideas?

    lineIn =
    csv.reader(file ("rits_feed\\ri ts_feed_US.csv" ,'rb'),delimite r='|')
    for emp in lineIn:
    cin=cin+1
    print cin
  • Tim Chase

    #2
    Re: strange problem

    This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
    at EOF I get around 10,000 less lines. Any ideas?
    >
    lineIn =
    csv.reader(file ("rits_feed\\ri ts_feed_US.csv" ,'rb'),delimite r='|')
    for emp in lineIn:
    cin=cin+1
    print cin
    What happens if you open it in ascii mode rather than binary mode?

    -tkc




    Comment

    • Bruno Desthuilliers

      #3
      Re: strange problem

      ken a écrit :
      This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
      at EOF I get around 10,000 less lines. Any ideas?
      Not without seeing the file.
      But I'm not sure I want to see it !-)
      lineIn =
      csv.reader(file ("rits_feed\\ri ts_feed_US.csv" ,'rb'),delimite r='|')
      for emp in lineIn:
      cin=cin+1
      print cin
      Note that manually tracking line count/number is way too boring. That's
      why Python as enumerate(seq) =indice, item

      Comment

      • Steve Holden

        #4
        Re: strange problem

        ken wrote:
        This file has 1,000,000+ lines in it, yet when I print the counter 'cin'
        at EOF I get around 10,000 less lines. Any ideas?
        >
        lineIn =
        csv.reader(file ("rits_feed\\ri ts_feed_US.csv" ,'rb'),delimite r='|')
        for emp in lineIn:
        cin=cin+1
        print cin
        My psychic powers indicate that double-quotes in the data are the most
        likely source of your problem. You may need to extract some statistics
        from the data to find out what's going on without examining each record
        individually.

        Like, for example, longest field-length for each column.

        regards
        Steve
        --
        Steve Holden +44 150 684 7255 +1 800 494 3119
        Holden Web LLC/Ltd http://www.holdenweb.com
        Skype: holdenweb http://holdenweb.blogspot.com
        Recent Ramblings http://del.icio.us/steve.holden

        Comment

        Working...