On Wed, 26 Jan 2005 18:25:09 -0500, "Dan Perl" <[EMAIL PROTECTED]> wrote:
>
>"rbt" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> Is there an easy way to exclude binary files (I'm working on Windows XP)
>> from the file list returned by os.walk()?
>>
>> Also, when reading files
Craig Ringer <[EMAIL PROTECTED]> wrote:
> That's not really safe when dealing with utf-8 files though, and IIRC
> with UCS2 or UCS4 as well. The Unicode BOM its self might (I'm not sure)
> qualify as ASCII.
Nope, both bytes in the BOM have the high-order bit set -- they're 0xFF
and 0xFE -- so the
rbt <[EMAIL PROTECTED]> wrote:
> Grant Edwards wrote:
> > On 2005-01-26, rbt <[EMAIL PROTECTED]> wrote:
> >
> >>Is there an easy way to exclude binary files (I'm working on
> >>Windows XP) from the file list returned by os.walk()?
> >
> > Sure, assuming you can provide a rigorous definition of '
The OP wrote:
> Is there an easy way to exclude binary files (I'm working on Windows
XP) from the file list returned by os.walk()?
Sure, piece of cake:
#!/usr/bin/env python
import os
def textfiles(path):
include = ('.txt', '.csv',)
for root, dirs, files in os.walk(path):
for name in
On Wed, 2005-01-26 at 17:32 -0500, rbt wrote:
> Grant Edwards wrote:
> > On 2005-01-26, rbt <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Is there an easy way to exclude binary files (I'm working on
> >>Windows XP) from the file list returned by os.walk()?
> >
> >
> > Sure, assuming you can provide a
On 2005-01-26, Larry Bates <[EMAIL PROTECTED]> wrote:
> There's no definitive way of telling a file is "non-ascii".
> Bytes in a binary file define perfectly good ascii characters.
As long as bit 7 is a 0.
Traditional ASCII only allows/defines the values 0x00 through
0x7f. If that's what is m
"rbt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Is there an easy way to exclude binary files (I'm working on Windows XP)
> from the file list returned by os.walk()?
>
> Also, when reading files and you're unsure as to whether or not they are
> ascii or binary, I've always th
you might want to look up the 'isascii' function...
i.e. - can be represented using just 7-bits.
--
http://mail.python.org/mailman/listinfo/python-list
There's no definitive way of telling a file is
"non-ascii". Bytes in a binary file define
perfectly good ascii characters. Windows
depends on file extensions to try to keep track
of the "type" of data in a file, but that isn't
foolproof. I can rename a plain ascii file with
a .EXE extension.
We
Grant Edwards wrote:
On 2005-01-26, rbt <[EMAIL PROTECTED]> wrote:
Is there an easy way to exclude binary files (I'm working on
Windows XP) from the file list returned by os.walk()?
Sure, assuming you can provide a rigorous definition of 'binary
files'. :)
non-ascii
--
http://mail.python.org/mai
On 2005-01-26, rbt <[EMAIL PROTECTED]> wrote:
> Is there an easy way to exclude binary files (I'm working on
> Windows XP) from the file list returned by os.walk()?
Sure, assuming you can provide a rigorous definition of 'binary
files'. :)
> Also, when reading files and you're unsure as to whet
Is there an easy way to exclude binary files (I'm working on Windows XP)
from the file list returned by os.walk()?
Also, when reading files and you're unsure as to whether or not they are
ascii or binary, I've always thought it safer to 'rb' on the read, is
this correct... and if so, what's the
12 matches
Mail list logo