CSV out of range

Discussion in 'Python' started by Anatoli Hristov, Dec 4, 2012.

  1. Hello,

    I tried to read a CSV file with 30000 products in it and index it into
    a list using

    file = open("ShopPrices.csv", "rbU")
    reader = csv.reader(file, delimiter=";")
    mylist = []

    for x in reader:
    mylist.append(x)

    The problem comes when I try to index the SKU array and the field is empty

    for sku in mylist:
    print sku[3]

    after the 3060 result I'm getting an error:

    IndexError: list index out of range

    and it seems that there I have empty array, I wanted to ignore the
    empty arrays using if statement, but it does the same.

    Thanks

    Anatoli
    Anatoli Hristov, Dec 4, 2012
    #1
    1. Advertising

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. Replies:
    46
    Views:
    951
    Antoon Pardon
    Jul 25, 2006
  2. Sacha Rook

    csv read clean up and write out to csv

    Sacha Rook, Nov 2, 2012, in forum: Python
    Replies:
    2
    Views:
    206
    Hans Mulder
    Nov 2, 2012
  3. Thomas Bach

    Re: CSV out of range

    Thomas Bach, Dec 4, 2012, in forum: Python
    Replies:
    0
    Views:
    121
    Thomas Bach
    Dec 4, 2012
  4. Anatoli Hristov

    Re: CSV out of range

    Anatoli Hristov, Dec 4, 2012, in forum: Python
    Replies:
    0
    Views:
    163
    Anatoli Hristov
    Dec 4, 2012
  5. Anatoli Hristov

    Re: CSV out of range

    Anatoli Hristov, Dec 4, 2012, in forum: Python
    Replies:
    2
    Views:
    147
    Anatoli Hristov
    Dec 4, 2012
Loading...

Share This Page