Re: What language to manipulate text files
- From: RedGrittyBrick <RedGrittyBrick@xxxxxxxxxxxxx>
- Date: Sun, 12 Jun 2005 13:49:04 +0000 (UTC)
rossnixon@xxxxxxxxx wrote:
I want to do some tricky text file manipulation, but have only a little programming knowledge.
What are the ideal languages for the following examples?
Since you posted this to a Perl newsgroup you probably know what kind of answer to expect. No language is ideal of course.
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 of the current folder called EATING with a new name of *FOOD*COPY.txt
I'd do this as a shell command using find.
2. Process each file as follows: Here is a simplified example of what I want to start from and end up with.
------------------------------------- input ......................... 'several unknown lines of text file Get apples from apples shop Get oranges from oranges shop Get plums from plums shop Get pears from pears shop Eat from apples, oranges, plums, pears 'whitespace at start of line is unimportant ......................... 'more unknown lines of text file Chapter 1 Several lines of text about apples in here Chapter 2 Several lines of text about oranges in here Chapter 3 Several lines of text about plums in here Chapter 4 Several lines of text about pears in here
------------------------------------- output ......................... 'several unknown lines of text file Get apples from apples shop Get oranges from oranges shop Get plums from plums shop Get pears from pears shop Get bagels from bagels shop 'the Get lines... Get donuts from donuts shop 'can be in any order Eat from apples, bagels, oranges, plums, donuts, pears 'whitespace at start of line is unimportant ......................... 'more unknown lines of text file Chapter 1 Several lines of text about apples in here Chapter 2 Several lines of text about bagels in here Chapter 3 Several lines of text about oranges in here Chapter 4 Several lines of text about plums in here Chapter 5 Several lines of text about donuts in here Chapter 6 Several lines of text about pears in here
Summary: I have added two new items to Get. I have put them into the comma-delimited list after searching for a particular fruit that each one should follow. The chapters are renumbered to match their position in the comma-delimited list. The "several lines of text" about each new item can be pulled from a new_foods.txt file (or a bagels.txt and a donuts.txt file).
I'd be happy to use Perl for that and would expect it to be relatively simple.
My first objective is to process the files as described.
Isn't that best achieved either by using a language you already know or paying someone experienced to write a program for you?
My second objective is to learn the best language for this sort of text manipulation.
Do you mean a) Be told what is best then learn it. b) Learn for yourself which is best.
If the latter, you'll need to learn all computer languages, implement a solution in each, repeat for a decade or so and then come to a view.
Frankly I don't think its worth the effort. Just pick a language that is close to something you know.
The language should run on Windows 98, XP and Linux.
Most popular languages do. Perl included.
Would Python be best, or would a macro-scripting thing like AutoHotKey work?
I'd pick a programming language not a macro scripting tool.
I thought about learning perl, but wonder about the learning curve and the maintainability of the code.
I'd say learning curve and maintainability depend more on your characteristics than on the characteristic of Perl.
IMHO Perl is usable for the tasks you mention even with only a rudimentary knowledge of Perl. After learning more than rudimentary perl you would typically be able to rewrite a working program to be more concise, elegant and faster.
Maintainability depends on lots of things that are language independant. I find that how maintainable a perl program is, depends almost entirely on how it was written (indentation, structure, comments, modules, algorithms and so on.) If you can write maintainable programs in any other language you'll be able to in Perl.
.
- References:
- What language to manipulate text files
- From: rossnixon
- What language to manipulate text files
- Prev by Date: Re: There's no LIMIT to my SPLITting headache.
- Next by Date: Re: Glob Q
- Previous by thread: What language to manipulate text files
- Next by thread: regex
- Index(es):
Relevant Pages
|