Hi there,

Currently I have a file with germanic names which are, unfortunately in this format:
B\xf6genschutz
As well as being mixed with those who actually have the correct character's in them.
What I am trying to do is convert the characters in the above format to the correct
format in a text file. The below 5 lines of code work fine, so it changes the static
line of text correctly, but when it reads lines in from the file, and i strip the endline off,
it doesn't conver the character's properly. It just keeps them as they are when printed
and outputted to the screen.

outfile = open("Output.py", 'w')
ingermanfile = open("GermanNames.txt", 'r')

line = "B\xf6genschutz"
print line.decode("iso-8859-1")
raw_input("Yeah")
   
   while 1:
      line = ingermanfile.readline()
      if not(line):
         break
      
      try:
          print line
          templine = line[:-1]
          temp = templine.decode("iso-8859-1")       
          print "'" + templine + "'"
          outfile.write(templine + "\n")
      except:
          raw_input("Here we are!")
          outfile.write(line)
          pass
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to