You may want to try a spilt if you are getting 8 different elements then it will give you a list of those elements <br><br><div class="gmail_quote">On Tue, Nov 9, 2010 at 3:21 PM, Costin Gamenț <span dir="ltr"><<a href="mailto:costin.gament@gmail.com">costin.gament@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Thank you for your timely response. Yes, I am sure "i" and "j" are<br>
from the same iteration. I should point out that "i" actually has 8<br>
elements and that str(i) gives a nice printout.<br>
<br>
On Tue, Nov 9, 2010 at 11:33 AM, Stefan Behnel <<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>> wrote:<br>
> Costin Gamenț, 09.11.2010 10:24:<br>
<div class="im">>><br>
>> Hi, I am trying to read a string as csv, but I encountered an odd<br>
>> problem. Here's my code:<br>
>><br>
>> csvfile = csv.reader(datastr.split('\n'), delimiter=';')<br>
>> r = ''<br>
>> for i in csvfile:<br>
>> for j in i:<br>
>> print j<br>
>> print i[0]<br>
>><br>
>> the "print j" statement works, but "print i[0]" returns "IndexError:<br>
>> list index out of range". Am I missing something?<br>
><br>
</div>> Are you sure the output you get from the "print j" is from the same loop<br>
> iteration as the "print i[0]"? Try adding "i" to the output.<br>
><br>
> Stefan<br>
><br>
> --<br>
<div><div></div><div class="h5">> <a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
><br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Nitin Pawar<br><br>