On Feb 2, 10:18 am, vsoler wrote:
> On 1 feb, 23:57, John Machin wrote:
>
> > On Feb 2, 6:18 am, vsoler wrote:
>
> > > r: in the open statement, why do you use 'rb' as 2nd argument? b is
> > > supposed to be binary, and my file is text!
>
> > Because unlike Stephen, r has read the csv manual. Bi
On 1 feb, 23:57, John Machin wrote:
> On Feb 2, 6:18 am, vsoler wrote:
>
>
>
> > r: in the open statement, why do you use 'rb' as 2nd argument? b is
> > supposed to be binary, and my file is text!
>
> Because unlike Stephen, r has read the csv manual. Binary mode is
> required to handle properly
On Feb 2, 6:18 am, vsoler wrote:
>
> r: in the open statement, why do you use 'rb' as 2nd argument? b is
> supposed to be binary, and my file is text!
Because unlike Stephen, r has read the csv manual. Binary mode is
required to handle properly cases like '\n' embedded in a field --
something whi
Stephen Hansen wrote:
>
>
> On Sun, Feb 1, 2009 at 9:24 AM, vsoler wrote:
>
> Hi,
>
> My foo.txt file contains the following:
>
> 1,"house","2,5"
> 2,"table","6,7"
> 3,"chair","-4,5"
>
> ... as seen with notepad.
>
> This file was created with the OpenOffice Calc
On 1 feb, 19:02, Stephen Hansen wrote:
> On Sun, Feb 1, 2009 at 9:24 AM, vsolerwrote:Hi,
> My foo.txt file contains the following:
> 1,"house","2,5"
> 2,"table","6,7"
> 3,"chair","-4,5"
> ... as seen with notepad.
> This file was created with the OpenOffice Calc spreadsheet, but since
> I use comm
On Sun, Feb 1, 2009 at 9:24 AM, vsoler wrote:Hi,
My foo.txt file contains the following:
1,"house","2,5"
2,"table","6,7"
3,"chair","-4,5"
... as seen with notepad.
This file was created with the OpenOffice Calc spreadsheet, but since
I use comma as the decimal separator for numbers,
On Feb 1, 11:50 am, Steve Holden wrote:
> And then, to conert the last field to numbers? ...
Are you asking me Steve? Well i did not want to short-circuit the OP's
learning process by spoon-feeding him the entire answer. I thought i
would give him a push in the right direction and observe the out
r wrote:
> Try the csv module
>
> py> import csv
> py> reader = csv.reader(open(csvfile, "rb"))
> py> for row in reader:
> print row
>
>
> ['1', 'house', '2,5 ']
> ['2', 'table', '6,7 ']
> ['3', 'chair', '-4,5 ']
And then, to conert the last field to numbers? ...
regards
Steve
--
Steve
Try the csv module
py> import csv
py> reader = csv.reader(open(csvfile, "rb"))
py> for row in reader:
print row
['1', 'house', '2,5 ']
['2', 'table', '6,7 ']
['3', 'chair', '-4,5 ']
--
http://mail.python.org/mailman/listinfo/python-list