Browsing text ; Python the right tool?
Jeff Shannon
jeff at ccvcorp.com
Tue Jan 25 19:46:54 EST 2005
Paul Kooistra wrote:
> 1. Does anybody now of a generic tool (not necessarily Python based)
> that does the job I've outlined?
> 2. If not, is there some framework or widget in Python I can adapt to
> do what I want?
Not that I know of, but...
> 3. If not, should I consider building all this just from scratch in
> Python - which would probably mean not only learning Python, but some
> other GUI related modules?
This should be pretty easy. If each record is CRLF terminated, then
you can get one record at a time simply by iterating over the file
("for line in open('myfile.dat'): ..."). You can have a dictionary of
classes or factory functions, one for each record type, keyed off of
the 2-character identifier. Each class/factory would know the layout
of that record type, and return a(n) instance/dictionary with fields
separated out into attributes/items.
The trickiest part would be in displaying the data; you could
potentially use COM to insert it into a Word or Excel document, or
code your own GUI in Python. The former would be pretty easy if
you're happy with fairly simple formatting; the latter would require a
bit more effort, but if you used one of Python's RAD tools (Boa
Constructor, or maybe PythonCard, as examples) you'd be able to get
very nice results.
Jeff Shannon
Technician/Programmer
Credit International
More information about the Python-list
mailing list