parse a csv file into a text file

Tim Chase python.list at tim.thechases.com
Thu Feb 6 19:49:28 CET 2014


[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





More information about the Python-list mailing list