[Tutor] Reading List from File

S Python spython01 at gmail.com
Thu Jul 31 22:12:34 CEST 2008


Emile, Amin:  Thank you both for your replies.  I was able to get it
working using:

>>> f = open(r'c:\test.txt', 'r')
>>> foo = f.readline().split(',')

Samir

On Thu, Jul 31, 2008 at 3:00 PM,  <amingv at gmail.com> wrote:
> Emile is rigth, there should be a () there.
> I'm sorry, im writing this from my cellphone and there's not a pc around XD.
> I didn,t know about the csv module either and had to do over complicated things to deal with embedded commas, thx for that too :).
>
> --
> Amin Rainmaker
>
> ---------- Forwarded message ----------
> From: Emile van Sebille <emile at fenx.com>
> To: tutor at python.org
> Date: Thu, 31 Jul 2008 11:34:56 -0700
> Subject: Re: [Tutor] Reading List from File
> S Python wrote:
>>>>>
>>>>> f = open(r'C:\test.txt', 'r')
>>>>> foo = f.readline.split(',')
>
> readline is the function/method name
> readline() executes that function/method and returns a value
>
> try typing in 'type(f.readline)' vs 'type(f.readline())'
>
> you can't .split() a function but you may split its return value.
>
>> but it fails when I try:
>>
>>>>> import csv
>>>>> myfile = open(r'c:\test.txt', 'r')
>>>>> data = csv.Reader(myfile, delimeter = ',')
>>
>
> Python is case sensitive -- reader is different from Reader.
>
> HTH,
>
> Emile
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


More information about the Tutor mailing list