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


Groups > comp.lang.python > #65550

Re: parse a csv file into a text file

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 <python.list@tim.thechases.com>
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 <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: parse a csv file into a text file
In-Reply-To <d74338a6-2969-4288-a462-4cc8701fd098@googlegroups.com>
References <5c268845-003f-4e24-b27a-c89e9fbfcc6c@googlegroups.com> <mailman.6429.1391647532.18130.python-list@python.org> <d74338a6-2969-4288-a462-4cc8701fd098@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 <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6454.1391712528.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[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

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


Thread

parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-05 16:10 -0800
  Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-05 16:17 -0800
    Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-05 23:56 -0800
  Re: parse a csv file into a text file Roy Smith <roy@panix.com> - 2014-02-05 19:33 -0500
    Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-05 23:52 -0800
      Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-06 00:15 -0800
        Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-06 00:48 -0800
      Re: parse a csv file into a text file MRAB <python@mrabarnett.plus.com> - 2014-02-06 13:16 +0000
        Re: parse a csv file into a text file Rustom Mody <rustompmody@gmail.com> - 2014-02-06 05:20 -0800
  Re: parse a csv file into a text file MRAB <python@mrabarnett.plus.com> - 2014-02-06 00:34 +0000
    Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-06 00:01 -0800
  Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-05 18:46 -0600
    Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-05 19:59 -0800
      Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-05 22:09 -0600
        Re: parse a csv file into a text file Asaf Las <roegltd@gmail.com> - 2014-02-05 20:17 -0800
    Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-06 00:07 -0800
      Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-06 12:49 -0600
  Re: parse a csv file into a text file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-06 00:50 +0000
  Re:parse a csv file into a text file Dave Angel <davea@davea.name> - 2014-02-05 19:57 -0500
    Re: parse a csv file into a text file Zhen Zhang <zhen.zhang.uoft@gmail.com> - 2014-02-06 00:12 -0800
      Re: parse a csv file into a text file Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-02-06 10:49 +0200
      Re: parse a csv file into a text file Dave Angel <davea@davea.name> - 2014-02-06 06:35 -0500
      Re: parse a csv file into a text file Dave Angel <davea@davea.name> - 2014-02-06 06:53 -0500
  Re: parse a csv file into a text file Terry Reedy <tjreedy@udel.edu> - 2014-02-05 22:01 -0500
  Re: parse a csv file into a text file Neil Cerutti <neilc@norwich.edu> - 2014-02-06 14:02 +0000
  Re: parse a csv file into a text file Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-06 17:40 +0000
  Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-06 11:51 -0600
  Re: parse a csv file into a text file Tim Golden <mail@timgolden.me.uk> - 2014-02-06 18:05 +0000
  Re: parse a csv file into a text file Neil Cerutti <neilc@norwich.edu> - 2014-02-06 18:34 +0000
  Re: parse a csv file into a text file Tim Chase <python.list@tim.thechases.com> - 2014-02-06 12:51 -0600

csiph-web