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


Groups > comp.lang.python > #34215

CSV out of range

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.unit0.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tolidtm@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.034
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'error:': 0.05; 'index': 0.13; 'ignore': 0.13; 'csv': 0.16; 'indexerror:': 0.16; 'mylist': 0.16; 'subject:CSV': 0.16; 'seems': 0.23; 'tried': 0.25; 'message- id:@mail.gmail.com': 0.27; 'arrays': 0.29; 'array': 0.29; "i'm": 0.29; 'file': 0.32; 'print': 0.32; 'getting': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'list': 0.35; 'same.': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'wanted': 0.36; 'does': 0.37; 'received:209': 0.37; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'hello,': 0.39; 'header:Received:5': 0.40; 'range': 0.60; 'products': 0.70
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=plEQSRy6AQO3YYHsSXFIBG/uAPh6Z9T9SqcnnhiYzpA=; b=l8E5JaPbDqZeQIO8Oc15COiwpolLp2c2NDAFH6RbvVMkdfVKwcLO89RFh8o2uhSiAs No0IgivuWnleCfwQzFBogMH0QVDmxxH+H49LHA2J28mPuCdrIWNpYA2/OZl2hRSFGNGk kkyseF9Wn4PPCXZTM94JDm5XAm3n4iLSXDGrX7J+9nIk4zt0popHVmK/vbwkE5tAzN2v X9qdvWX09OI3OXYAFk4IVlNWRE8Wns/gtpmXzmSwy6jxnO57TL+7yqllczFsdwPtwFvF FsqxwVfw4PGnVgF3MkG/tWgtfbtgQqTIzD7k1oo9AbFkrt+G+YkonizqBnvYQch2cvxh MJlA==
MIME-Version 1.0
Date Tue, 4 Dec 2012 12:00:05 +0100
Subject CSV out of range
From Anatoli Hristov <tolidtm@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.456.1354618808.29569.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354618808 news.xs4all.nl 6917 [2001:888:2000:d::a6]:39076
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34215

Show key headers only | View raw


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

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


Thread

CSV out of range Anatoli Hristov <tolidtm@gmail.com> - 2012-12-04 12:00 +0100

csiph-web