What language to manipulate text files

Roose b at b.b
Sun Jun 12 02:53:25 EDT 2005


Why do people keep asking what language to use for certain things in the 
Python newsgroup?  Obviously the answer is going to biased.

Not that it's a bad thing because I love Python, but it doesn't make sense 
if you honestly want an objective opinion.

R

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
>
> 2. Process each file as follows:
> Here is a simplified example of what I want as input and output.
>
> ------------------------------------- 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 to put each one after;
> 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).
>
> 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?
> I thought about Perl, but think I would learn bad habits and have hard
> to read code.
>
> Thanks, Ross 





More information about the Python-list mailing list