<br>This is my first posting to this list. Perhaps this has a very easy
answer but before deciding to post this message I consulted a bunch of
Python manuals and on-line reference documents to no avail. I would be
very grateful if someone could lend me a hand with this.
<br>Here's the problem I want to solve. I have a lot of files with the
following name structure:
<br>These are different text documents that I want to process for an NLP
project I'm starting. Each one of the texts belongs to a different
century and it is important to be able to include the information about
the century in the name of the file as well as inside the text.
<br>Then I have another text file containing information about the century
each one of the texts was written. This document has the following
<br>What I would like to do is to write a little script that would do the
<br>. Read each row of the text containing information about the centuries
each one of the texts was written
<br>. Change the name of the file whose name starts with the code in the
first column in the following way
<br> A-01-namex.txt --> A-01-namex_13-2.txt
<br> Where 13-1 means: 13th 2nd half. Obviously this information would
com from the second column in the text: 1278 (the first two digits + 1 =
century; if the 3rd and 4th digits > 50, then 2; if < 50 then 1)
<br>Then in the same script or in a new one, I would need to open each one
of the texts and add information about the century they were written on
the first line preceded by some symbol (e.g @13-2)
<br>I've found a lot of information about changing file names (so I know
that I should be importing the os module), but none of the examples that
were cited involved getting the information for the file changing
operation from the contents of a document.
<br>As you can imagine, I'm pretty green in Python programming and I was
hoping the learn by doing method would work. I need to get on with this
project, though, and I'm kind of stuck. Any help you guys can give me
will be very helpful.