Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.05; 'subject:text': 0.05; 'subject:file': 0.07; 'tries': 0.07; 'indexes': 0.09; 'subject:into': 0.09; '-tkc': 0.16; '[1].': 0.16; 'fine.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'indexerror:': 0.16; 'index': 0.16; 'wrote:': 0.18; 'split': 0.19; 'print': 0.22; 'error': 0.23; 'url:moin': 0.24; 'file.': 0.24; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; "doesn't": 0.30; 'gives': 0.31; 'posting': 0.31; 'reply.': 0.31; 'url:wiki': 0.31; 'run': 0.32; 'url:python': 0.33; 'actual': 0.34; 'case,': 0.35; 'but': 0.35; 'google': 0.35; 'there': 0.35; 'charset:us-ascii': 0.36; 'possible': 0.36; 'url:org': 0.36; 'two': 0.37; 'list': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'even': 0.60; 'read': 0.60; 'blank': 0.60; 'range': 0.61; "you're": 0.61; "you've": 0.63; 'more': 0.64; 'received:50.22': 0.84; 'zhang': 0.84 Date: Thu, 6 Feb 2014 12:49:28 -0600 From: Tim Chase To: python-list@python.org Subject: Re: parse a csv file into a text file In-Reply-To: References: <5c268845-003f-4e24-b27a-c89e9fbfcc6c@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Authenticated-Sender: tim@thechases.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391712528 news.xs4all.nl 2908 [2001:888:2000:d::a6]:35680 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65550 [first, it looks like you're posting via Google Groups which annoyingly double-spaces everything in your reply. It's possible to work around this, but you might want to subscribe via email or an actual newsgroup client. You can read more at https://wiki.python.org/moin/GoogleGroupsPython ] On 2014-02-06 00:07, Zhen Zhang wrote: > Does the split make a list or tuple? In this case, it happens to return a list, which you can check with print type("one two three".split()) However, also in this case, it doesn't matter, since either indexes just fine. > when i do location=line[1], > it gives me a error even though the program did run correctly and > output the correct file. location=line[1] > IndexError: list index out of range Then it looks like you've got a blank line that doesn't actually have data in it, so when it tries index into it, the only thing there is [0], not [1]. As the message suggests :) -tkc