Danny Yoo Wrote in message:
>
>
>
>
>> Hopefully, this makes the point clearer: we must not try to decode
>> individual lines. By that time, the damage has been done: the act of
>> trying to break the file into lines by looking naively at newline byte
>> characters is invalid when certain cha
>
> for encoding in ('utf-8', 'utf-16', 'utf-32'):
> for i in range(0x11):
> aChar = unichr(i)
> try:
> someBytes = aChar.encode(encoding)
> if '\n' in someBytes:
> print("%r contains a newlin
>> A small note about performance here. If your log files are very large
>> (say, hundreds of thousands or millions of lines) you will find that
>> this part is *horribly horrible slow*. There's two problems, a minor and
>> a major one.
>
> Ah, actually I was mistaken about that. I forgot that for
On Sat, May 03, 2014 at 11:53:27AM +1000, Steven D'Aprano wrote:
> [...]
> > fullPath = [] # declare (initially empty) lists
> > truncPath = []
> >
> > with codecs.open('/var/log/rsyncd.log', 'r') as rsyncd_log:
> > for line in rsyncd_log.readlines():
> > fullPath += [line.decode('u
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi Steven,
On 03/05/14 02:53, Steven D'Aprano wrote:
> Hi Bob, and welcome!
>
> My responses interleaved with yours, below.
>
> On Fri, May 02, 2014 at 11:19:26PM +0100, Bob Williams wrote:
>> -BEGIN PGP SIGNED MESSAGE- Hash: SHA1
>>
>> Hi,
Hi Bob, and welcome!
My responses interleaved with yours, below.
On Fri, May 02, 2014 at 11:19:26PM +0100, Bob Williams wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi,
>
> I'm fairly new to coding and python. My system is linux (openSUSE
> 13.1).
Nice to know. And I see you h
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi,
I'm fairly new to coding and python. My system is linux (openSUSE
13.1). I've written the following code to examine a log file, and
extract strings from certain lines if two conditions are met, namely
that the file has been modified today, and the