[Tutor] process and modify a list of strings, in place

John Martinetti smed at missinglynx.net
Sat Feb 12 15:43:46 CET 2011


Hi Mark -

The characters skipped were unintentional, I sliced up the report based on
starting/ending column numbers that I somewhat guessed and massaged by
merely comparing the output of the openPOs list to the actual report.  There
might even been some room to massage those boundaries further to be quite
honest.

The report writer we use is called Cyberquery and it works on CISAM database
flat-files (as well as other databases).  It's awful with this pseudo/SQL
reporting language that just trips me up constantly when compared to any of
the SQL languages.  And the fact that we run our business on a
non-relational database is archaic, I could drone on & on about that but
it's just makes my blood-pressure rise.   Anyway - the short story is that I
dont have many choices in output formats from the report-writer.  I can
export to normal text files, Excel spreadsheets, DIF format and HTML.
Those are the options.  I can't believe there's no CSV format, that would
make my life a lot easier, but there isn't.  I wish there was.  I've even
thought that it might be worth my while to try exporting the HTML and
parsing it out from there....could be more consistent, but it would require
experimentation.

Anywho - thanks for the suggestion about the CSV module, I can actually use
that in the future too, just not for this project.  Thanks a bunch for
bringing that to my attention, I was not aware of that module and it may
come in very useful for me.



{quote}
I noticed when splitting up your record line there is a character skipped
between each field.   A delimiter perhaps?  Then you may be interested in
the csv module.  Assuming the delimiter is '|', the following code will
produce the same result in openPOs:

>
>   import csv
>   with open('open_pos.txt','rb') as f:
>       reader = csv.reader(f,delimiter='|')
>       openPOs = list(reader)
>   print openPOs
>
> Note you may have to specify some more parameters to csv.reader depending
> on your file "dialect".  See the csv.Dialect class for details.
>
> -Mark
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

{/quote}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110212/4530d64c/attachment.html>


More information about the Tutor mailing list