<div dir="ltr">oops it is reader not Reader (all lower case), so this line : data = csv.Reader(myfile, delimeter = ',')<br>should be data = csv.reader(myfile, delimeter = ',')<br><br><br><div class="gmail_quote">
2008/7/31 S Python <span dir="ltr"><<a href="mailto:spython01@gmail.com">spython01@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Everyone,<br>
<br>
Thanks for the variety of responses in such a short amount of time.<br>
This distribution list is incredible.<br>
<br>
Sorry for the delayed reply as I wanted to test what everyone<br>
suggested, so here goes:<br>
<br>
-------------------------------<br>
<br>
@Amin: I tried your suggestion, but perhaps I don't understand your<br>
syntax. Here is what I tried and the resulting error message:<br>
<br>
>>> f = open(r'C:\test.txt', 'r')<br>
>>> foo = f.readline.split(',')<br>
<br>
Traceback (most recent call last):<br>
File "<pyshell#16>", line 1, in <module><br>
foo = f.readline.split(',')<br>
AttributeError: 'builtin_function_or_method' object has no attribute 'split'<br>
<br>
Do you know what I did wrong?<br>
<br>
-------------------------------<br>
<br>
@Emad, Brett: Thank you for your solutions. They do exactly what I<br>
was looking for.<br>
<br>
-------------------------------<br>
<br>
@Chad: Thanks for your suggestion. I think I like it best for its simplicity.<br>
<br>
-------------------------------<br>
<br>
@Emile, Monika, kinuthi: The CSV standard library looks interesting<br>
but I am having mixed results in implementing it. For example, it<br>
works when I try this:<br>
<br>
>>> reader = csv.reader(open(r'c:\test.txt', 'rb'))<br>
>>> for row in reader:<br>
print row<br>
<br>
<br>
['aaa', 'bbb', 'ccc']<br>
<br>
but it fails when I try:<br>
<br>
>>> import csv<br>
>>> myfile = open(r'c:\test.txt', 'r')<br>
<div class="Ih2E3d">>>> data = csv.Reader(myfile, delimeter = ',')<br>
<br>
</div>Traceback (most recent call last):<br>
File "<pyshell#26>", line 1, in <module><br>
<div class="Ih2E3d"> data = csv.Reader(myfile, delimeter = ',')<br>
</div>AttributeError: 'module' object has no attribute 'Reader'<br>
<br>
The error looks similar to what I received when I tried Amin's<br>
approach. Am I missing something?<br>
<br>
-------------------------------<br>
<br>
It's interesting to note that for the solutions to work correctly, I<br>
had to remove the quotation marks from the input file.<br>
<br>
Thanks again to EVERYONE who took the time to respond. I appreciate your help.<br>
<br>
Samir<br>
<div><div></div><div class="Wj3C7c">_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br></div>