Tim Williams wrote:
Are you running on windows?
No. Of course I could use some installed tool, like ls, but I
want a portable solution.
HTH :)
Not really. Windows is only a niche for desktop systems. In my
case the python script is running on a heterogenous grid
monitoring system accessing a
Wolfgang Draxinger wrote:
I got, hmm not really a problem, more a question of elegance:
In a current project I have to read in some files in a given
directory in chronological order, so that I can concatenate the
contents in those files into a new one (it's XML and I have to
concatenate
Larry Bates kirjoitti:
Wolfgang Draxinger wrote:
Jussi Salmela wrote:
I'm not claiming the following to be more elegant, but I would
do it like this (not tested!):
src_file_paths = dict()
prefix = sourcedir + os.sep
for fname in os.listdir(sourcedir):
if match_fname_pattern(fname):
H folks,
I got, hmm not really a problem, more a question of elegance:
In a current project I have to read in some files in a given
directory in chronological order, so that I can concatenate the
contents in those files into a new one (it's XML and I have to
concatenate some subelements, about 4
Wolfgang Draxinger kirjoitti:
H folks,
I got, hmm not really a problem, more a question of elegance:
In a current project I have to read in some files in a given
directory in chronological order, so that I can concatenate the
contents in those files into a new one (it's XML and I have to
Jussi Salmela wrote:
I'm not claiming the following to be more elegant, but I would
do it like this (not tested!):
src_file_paths = dict()
prefix = sourcedir + os.sep
for fname in os.listdir(sourcedir):
if match_fname_pattern(fname):
fpath = prefix + fname
Wolfgang Draxinger wrote:
Jussi Salmela wrote:
I'm not claiming the following to be more elegant, but I would
do it like this (not tested!):
src_file_paths = dict()
prefix = sourcedir + os.sep
for fname in os.listdir(sourcedir):
if match_fname_pattern(fname):
fpath =
Wolfgang Draxinger [EMAIL PROTECTED] writes:
src_file_paths = dict()
for fname in os.listdir(sourcedir):
fpath = sourcedir+os.sep+fname
if not match_fname_pattern(fname): continue
src_file_paths[os.stat(fpath).st_mtime] = fpath
for ftime in
Wolfgang Draxinger kirjoitti:
Jussi Salmela wrote:
I'm not claiming the following to be more elegant, but I would
do it like this (not tested!):
src_file_paths = dict()
prefix = sourcedir + os.sep
for fname in os.listdir(sourcedir):
if match_fname_pattern(fname):
fpath =
Wolfgang Draxinger wrote:
However this code works (tested) and behaves just like listdir,
only that it sorts files chronologically, then alphabetically.
def listdir_chrono(dirpath):
import os
files_dict = dict()
for fname in os.listdir(dirpath):
Larry Bates wrote:
3) You didn't handle the possibility that there is s
subdirectory
in the current directory. You need to check to make sure it
is a file you are processing as os.listdir() returns files
AND directories.
Well, the directory the files are in is not supposed to have
On 20/02/07, Wolfgang Draxinger [EMAIL PROTECTED] wrote:
H folks,
I got, hmm not really a problem, more a question of elegance:
In a current project I have to read in some files in a given
directory in chronological order, so that I can concatenate the
contents in those files into a new one
12 matches
Mail list logo