[Tutor] Take file and dice
Gonçalo Rodrigues
op73418@mail.telepac.pt
Thu Dec 12 10:16:00 2002
----- Original Message -----
From: "Adam Vardy" <anvardy@roadrunner.nf.net>
To: <tutor@python.org>
Sent: Thursday, December 12, 2002 2:09 PM
Subject: [Tutor] Take file and dice
> Could I find a program like this?
Probably not, but let's run down through your spec and see *what we need* to
accomplish the task.
>Will search down through a text
> file.
You need to know how to open (text) files.
>Each time a line is found that starts like here,
You need to scan the file line by line.
(A) You need to check if a line starts with a given sequence of chars.
>take the
> filename, create it,
If a line starts with the given sequence of characters:
(somehow) grab a filename from the line
>and save the following text to it, up until a
> line starts with some non alphabetic symbol.
for each line following and "until it starts with some non alphabetic
symbol":
save line which means: open a new file for writing with the filename we
grabbed and write line to file.
>And then continue looking
> for this part again, for a new file.
Go back to (A) and do it all again.
>So, you end up with a bunch of
> new files in some path.
>
> # file filename
>
> Also, take the text file, and remove all lines that start like
>
> ...
> >>>
if line starts with ">>>":
delete it.
>
> and save the result.
>
Rewrite what we have to our original file.
> --
> Adam Vardy
This should give you a (simple) prototype. Now get to work! ;-)
All the best,
G. Rodrigues