How to read space separated file in python?
steve at REMOVE-THIS-cybersource.com.au
Fri Nov 21 10:08:41 CET 2008
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.
> 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 the character separately like:
> str=0 and str2=०
> How can i do this?
> please give me solution?
Well, because you said please...
I assume the encoding of the second column is utf-8. You need something
column0 = 
column1 = 
for line in open('somefile', 'r'):
a, b = line.split()
More information about the Python-list