Re: String multi-replace

2010-11-18 Thread Frederic Rentsch
On Wed, 2010-11-17 at 21:12 -0800, Sorin Schwimmer wrote: > Thanks for your answers. > > Benjamin Kaplan: of course dict is a type... silly me! I'll blame it on the > time (it's midnight here). > > Chris Rebert: I'll have a look. > > Thank you both, > SxN > > Forgive me if this is off the tr

Re: String multi-replace

2010-11-18 Thread Dave Angel
On 2:59 PM, Sorin Schwimmer wrote: Steven D'Aprano: the original file is 139MB (that's the typical size for it). Eliminating diacritics is just a little toping on the cake; the processing is something else. Thanks anyway for your suggestion, SxN PS Perhaps I should have mention that I'm on Py

Re: String multi-replace

2010-11-18 Thread MRAB
On 18/11/2010 04:30, Benjamin Kaplan wrote: On Wed, Nov 17, 2010 at 11:21 PM, Sorin Schwimmer wrote: Hi All, I have to eliminate diacritics in a fairly large file. Inspired by http://code.activestate.com/recipes/81330/, I came up with the following code: #! /usr/bin/env python import re n

Re: String multi-replace

2010-11-18 Thread Peter Otten
Sorin Schwimmer wrote: > I have to eliminate diacritics in a fairly large file. > > Inspired by http://code.activestate.com/recipes/81330/, I came up with the > following code: Here's the unicode.translate()-based approach spelt out: http://effbot.org/zone/unicode-convert.htm Peter -- http://

Re: String multi-replace

2010-11-17 Thread Sorin Schwimmer
Steven D'Aprano: the original file is 139MB (that's the typical size for it). Eliminating diacritics is just a little toping on the cake; the processing is something else. Thanks anyway for your suggestion, SxN PS Perhaps I should have mention that I'm on Python 2.7 -- http://mail.python.org

Re: String multi-replace

2010-11-17 Thread Sorin Schwimmer
Thanks for your answers. Benjamin Kaplan: of course dict is a type... silly me! I'll blame it on the time (it's midnight here). Chris Rebert: I'll have a look. Thank you both, SxN -- http://mail.python.org/mailman/listinfo/python-list

Re: String multi-replace

2010-11-17 Thread Steven D'Aprano
On Wed, 17 Nov 2010 20:21:06 -0800, Sorin Schwimmer wrote: > Hi All, > > I have to eliminate diacritics in a fairly large file. What's "fairly large"? Large to you is probably not large to your computer. Anything less than a few dozen megabytes is small enough to be read entirely into memory.

Re: String multi-replace

2010-11-17 Thread Chris Rebert
On Wed, Nov 17, 2010 at 8:21 PM, Sorin Schwimmer wrote: > Hi All, > > I have to eliminate diacritics in a fairly large file. > > Inspired by http://code.activestate.com/recipes/81330/, I came up with the > following code: > > #! /usr/bin/env python > > import re > > nodia={chr(196)+chr(130):'A',

Re: String multi-replace

2010-11-17 Thread Benjamin Kaplan
On Wed, Nov 17, 2010 at 11:21 PM, Sorin Schwimmer wrote: > Hi All, > > I have to eliminate diacritics in a fairly large file. > > Inspired by http://code.activestate.com/recipes/81330/, I came up with the > following code: > > #! /usr/bin/env python > > import re > > nodia={chr(196)+chr(130):'A',

String multi-replace

2010-11-17 Thread Sorin Schwimmer
Hi All, I have to eliminate diacritics in a fairly large file. Inspired by http://code.activestate.com/recipes/81330/, I came up with the following code: #! /usr/bin/env python import re nodia={chr(196)+chr(130):'A', # mamaliga chr(195)+chr(130):'A', # A^ chr(195)+chr(142):'I',