<br><br><div class="gmail_quote">On Sat, Oct 2, 2010 at 11:56 AM, Josep M. Fontana <span dir="ltr">&lt;<a href="mailto:josep.m.fontana@gmail.com">josep.m.fontana@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Then I have another text file containing information about the century 
each one of the texts was written. This document has the following 
structure:
<br>
<br>A-01, 1278
<br>A-02, 1501
<br>...
<br>N-09, 1384
<br>
<br></blockquote><div> </div><div>To process this, I&#39;d check out the CSV (Comma Separated Values) module.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
What I would like to do is to write a little script that would do the 
following:
<br>
<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>
<br>        A-01-namex.txt --&gt; A-01-namex_13-2.txt
<br>
<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 &gt; 50, then 2; if &lt; 50 then     1)
<br>
<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>
<br>I&#39;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. </blockquote></div><div><br></div>If it were me, I&#39;d build a string using the information you want, then add &quot;.txt&quot; or whatever to the end of it, then use the os module to change the filenames.<br clear="all">
<br>-- <br>Greg Bair<div><a href="mailto:gregbair@gmail.com" target="_blank">gregbair@gmail.com</a></div><br>