What language to manipulate text files

Terry Hancock hancock at anansispaceworks.com
Sun Jun 12 08:18:09 CEST 2005


On Saturday 11 June 2005 11:37 pm, ross wrote:
> I want to do some tricky text file manipulation on many files, but have
> only a little programming knowledge.
[...]

> Would Python be best, or would a macro-scripting thing like AutoHotKey
> work?
> I thought about Perl, but think I would learn bad habits and have hard
> to read code.

Both Perl and Python are *extremely* good at this kind of work.  This is
pretty much what inspired Perl, and Python implements most of the same
toolset.  You will solve many of these kinds of problems using "regular
expressions"  (built-in first-class object in Perl, created from strings in
Python using the "re" module).

No surprise of course that I would choose Python.  Mainly because of what
it provides beyond regular expressions. Many simple cases can be handled
with string methods in Python (check the Sequence types information in the
built-ins section of the Library Reference -- also look at the "string" module,
though it's usually easier to use the string methods approach).

You will probably end up with more readable code using Python and
take less time to develop sufficient proficiency to do the job with it. 


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Python-list mailing list