Re: Handling text lines from files with some (few) starnge chars

2010-06-05 Thread Paulo da Silva
Em 06-06-2010 04:05, John Machin escreveu: > On Jun 6, 12:14 pm, MRAB wrote: >> Paulo da Silva wrote: ... >>> OK! This fixes my current problem. I used encoding="iso-8859-15". This >>> is how my text files are encoded. >>> But what about a more general case where the encoding of the text file >>>

Re: Handling text lines from files with some (few) starnge chars

2010-06-05 Thread John Machin
On Jun 6, 12:14 pm, MRAB wrote: > Paulo da Silva wrote: > > Em 06-06-2010 00:41, Chris Rebert escreveu: > >> On Sat, Jun 5, 2010 at 4:03 PM, Paulo da Silva > >> wrote: > > ... > > >> Specify the encoding of the text when opening the file using the > >> `encoding` parameter. For Windows-1252 for e

Re: Handling text lines from files with some (few) starnge chars

2010-06-05 Thread MRAB
Paulo da Silva wrote: Em 06-06-2010 00:41, Chris Rebert escreveu: On Sat, Jun 5, 2010 at 4:03 PM, Paulo da Silva wrote: ... Specify the encoding of the text when opening the file using the `encoding` parameter. For Windows-1252 for example: your_file = open("path/to/file.ext", 'r', encoding

Re: Handling text lines from files with some (few) starnge chars

2010-06-05 Thread Paulo da Silva
Em 06-06-2010 00:41, Chris Rebert escreveu: > On Sat, Jun 5, 2010 at 4:03 PM, Paulo da Silva > wrote: ... > > Specify the encoding of the text when opening the file using the > `encoding` parameter. For Windows-1252 for example: > > your_file = open("path/to/file.ext", 'r', encoding='cp1252') >

Re: Handling text lines from files with some (few) starnge chars

2010-06-05 Thread python
Chris, > Specify the encoding of the text when opening the file using the `encoding` > parameter. For Windows-1252 for example: > > your_file = open("path/to/file.ext", 'r', encoding='cp1252') This looks similar to the codecs module's functionality. Do you know if the codecs module is still req

Re: Handling text lines from files with some (few) starnge chars

2010-06-05 Thread Chris Rebert
On Sat, Jun 5, 2010 at 4:03 PM, Paulo da Silva wrote: > I need to read text files and process each line using string > comparisions and regexp. > > I have a python2 program that uses .readline to read each > line as a string. Then, processing it was a trivial job. > > With python3 I got error mess

Handling text lines from files with some (few) starnge chars

2010-06-05 Thread Paulo da Silva
I need to read text files and process each line using string comparisions and regexp. I have a python2 program that uses .readline to read each line as a string. Then, processing it was a trivial job. With python3 I got error messagew like: File "./pp1.py", line 93, in RL line=inf.readline()