<div>Max - Thanks for your reply. The text files are not in csv format and I will need to figure out how to separate the fields. Space as a separator will not work as values have spaces in them. The current text file I am looking at seems to have fields that are at fixed width and the each line I want are encapsulated in "". The example you showed below will be usefull once I accomplish the above task.
</div>
<div> </div>
<div>Chris - Thank you for your reply. The link you provided have some examples of file and string manipulation which will be a very useful read.</div>
<div> </div>
<div>Alden<br><br> </div>
<div><span class="gmail_quote">On 5/16/07, <b class="gmail_sendername">Max Slimmer</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:max@theslimmers.net" target="_blank">max@theslimmers.net</a>
> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">You indicated you receive text files, if they are comma delimited you can parse them with the csv library and thus read them into python lists of lists
</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">onece you have your data in a list of lists you could simply operate on it there or you could create objects from each list element leaving you with a list of objects exch representing one row.
</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">say you keep it simple and you have incoming data consisting of name, rate, amt. </font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">>>> data = [['name1',12.5, 123.66],['name2',5.6,421]]</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">>>> data</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">[['name1', 12.5, 123.66], ['name2', 5.5999999999999996, 421]]</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">you can sum all the amt's with </font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">>>> tot = sum(row[2] for row in data)</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">>>> tot<br>544.65999999999997</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">or you can sort the data by rate:</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">>>> data.sort(key=lambda i:i[1]) # see <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305304" target="_blank">
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/305304</a> for interesting things to do with sort</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">>>> data<br>[['name2', 5.5999999999999996, 421], ['name1', 12.5, 123.66]]</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">play with the interactive interpreter </font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2"></font></span> </div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">max</font></span></div>
<div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2"></font></span> </div><br>
<blockquote dir="ltr" style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<div lang="en-us" dir="ltr" align="left">
<hr>
<font face="Tahoma" size="2"><b>From:</b> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:baypiggies-bounces@python.org" target="_blank">baypiggies-bounces@python.org</a> [mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:baypiggies-bounces@python.org" target="_blank">
baypiggies-bounces@python.org</a>] <b>On Behalf Of </b>Alden Meneses<br><b>Sent:</b> Wednesday, May 16, 2007 10:45 AM<br><b>To:</b> <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:baypiggies@python.org" target="_blank">
baypiggies@python.org</a><br><b>Subject:</b> [Baypiggies] newbie question - automating my reporting tasks<br></font><br> </div>
<div><span>
<div></div>
<div>Hello all,</div>
<div> </div>
<div>It does seem that Python is easier to lean than PERL. and I like the interpreter.</div>
<div> </div>
<div>I have some text files that I download from an AS400 and format with Excel. Basically I convert the text to columns then sort and subtotal. The results are then emailed to various people and also used in other reports. Haven't really thought out how to automate this whole process but wanted to start with a project to learn python and go from there.
</div>
<div> </div>
<div>I have skimmed throught the python tutorial and now getting into python in a nutshell, 2nd edition and would welcome any thoughts or suggestions in getting my project off the ground. I've taken programming courses in college - C, C++, PERL, FORTRAN, PASCAL, UNIX shell scripting and its been awhile since I had to rely on it.
</div>
<div> </div>
<div>Thanks in advance,</div>
<div>Alden</div></span></div></blockquote></div></blockquote></div><br>