Re: How to read space separated file in python?

2008-11-21 Thread ganesh gajre
Hey Steve and Joe , Thank you very much. There is yet little problem. But sure all the Pythonist will help me in that. Ginovation, "Every thing is impossible unless you make it possible" On Sat, Nov 22, 2008 at 5:10 AM, Steve Holden <[EMAIL PROTECTED]> wrote: > Joe Strout wrote: > [...] > > Par

Re: How to read space separated file in python?

2008-11-21 Thread Steve Holden
Joe Strout wrote: [...] > Partition handles these cases correctly (at least, within the OP's > specification that the value of "b" should be whatever comes after the > first space). I believe if you read the OP's post again you will see that he specified two non-space items per line. You really *

Re: How to read space separated file in python?

2008-11-21 Thread Gabriel Genellina
En Fri, 21 Nov 2008 14:13:23 -0200, Joe Strout <[EMAIL PROTECTED]> escribió: Right -- so using split() gives you the wrong answer for two different reasons. Try these: >>> line = "1 x" >>> a, b = line.split() # b == "x", which is correct >>> line = "2 " >>> a, b = line.split() # co

Re: How to read space separated file in python?

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 9:00 AM, Steve Holden wrote: Joe Strout wrote: On Nov 21, 2008, at 2:08 AM, Steven D'Aprano wrote: a, b = line.split() Note that in a case like this, you may want to consider using partition instead of split: a, sep, b = line.partition(' ') This way, if there hap

Re: How to read space separated file in python?

2008-11-21 Thread Steve Holden
Joe Strout wrote: > On Nov 21, 2008, at 2:08 AM, Steven D'Aprano wrote: > >>a, b = line.split() > > Note that in a case like this, you may want to consider using partition > instead of split: > > a, sep, b = line.partition(' ') > > This way, if there happens to be more than one space (for

Re: How to read space separated file in python?

2008-11-21 Thread Joe Strout
On Nov 21, 2008, at 2:08 AM, Steven D'Aprano wrote: a, b = line.split() Note that in a case like this, you may want to consider using partition instead of split: a, sep, b = line.partition(' ') This way, if there happens to be more than one space (for example, because the Unicode c

Re: How to read space separated file in python?

2008-11-21 Thread Peter Otten
ganesh gajre wrote: > Hi all, > > I want to read file which is mapping file. Used in to map character from > ttf to unicode. > eg > > Map file contain data in the following way: > > 0 ० > 1 १ > 2 २ > 3 ३ > 4 ४ > 5 ५ > 6 ६ > 7 ७ > 8 ८ > 9 ९ > > Like this. Please use any unicode editor to view t

Re: How to read space separated file in python?

2008-11-21 Thread Steven D'Aprano
On Fri, 21 Nov 2008 14:16:13 +0530, ganesh gajre wrote: > Hi all, > > I want to read file which is mapping file. Used in to map character from > ttf to unicode. > eg > > Map file contain data in the following way: > > 0 ० > 1 १ > 2 २ > 3 ३ > 4 ४ > 5 ५ > 6 ६ > 7 ७ > 8 ८ > 9 ९ > > Like this. Ple

How to read space separated file in python?

2008-11-21 Thread ganesh gajre
Hi all, I want to read file which is mapping file. Used in to map character from ttf to unicode. eg Map file contain data in the following way: 0 ० 1 १ 2 २ 3 ३ 4 ४ 5 ५ 6 ६ 7 ७ 8 ८ 9 ९ Like this. Please use any unicode editor to view the text if it not properly shown. Now i want to read both th