Re: What language to manipulate text files
- From: Michael Hoffman <cam.ac.uk@xxxxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 08:45:55 +0100
ross wrote:
I want to do some tricky text file manipulation on many files, but have only a little programming knowledge.
What are the ideal languages for the following examples?
1. Starting from a certain folder, look in the subfolders for all filenames matching *FOOD*.txt Any files matching in each folder should be copied to a new subfolder within the current folder called EATING with a new name of *FOOD*COPY.txt
This should get you started:
import errno from path import path # http://www.jorendorff.com/articles/python/path/
dst_dirpath = path("EATING")# create dst_dirpath
try:
dst_dirpath.makedirs() # make destination directory and its parents
except OSError, err: # error!
if err.errno = errno.EEXIST: # might just be that it already exists
if not dst_dirpath.isdir(): # and it's a directory
raise # if not, raise an exceptionfor filepath in path(".").walkfiles("*FOOD*.txt"):
infile = file(filepath)
outfile = file(dst_dirpath.joinpath(filepath.namebase+"_COPY.txt"))...do processing here...
My first objective is to process the files as described. My second objective is to learn the best language for this sort of text manipulation. The language should run on Windows 98, XP and Linux.
Would Python be best, or would a macro-scripting thing like AutoHotKey work?
Personally, I'd use Python, but what do you expect when you ask here? -- Michael Hoffman .
- References:
- What language to manipulate text files
- From: ross
- What language to manipulate text files
- Prev by Date: Re: Dealing with marketing types...
- Next by Date: Streaming Data Error in .read() (HTTP/ICY) Possible Bug?
- Previous by thread: Re: What language to manipulate text files
- Next by thread: Re: What language to manipulate text files
- Index(es):
Relevant Pages
|