Considering migrating to Python from Visual Basic 6 for engineering applications

Tim Chase python.list at tim.thechases.com
Thu Feb 18 14:28:07 EST 2016


On 2016-02-18 07:33, wrong.address.1 at gmail.com wrote:
> Another question I have is regarding reading numerical data from
> text files. Is it necessary to read one character at a time, or can
> one read like in Fortran and Basic (something like Input #5, X1,
> X2, X3)?

A lot of my work is extracting data from text files.  If it's
CSV-format data, Python's "csv" module in the standard library offers
some nice tools for doing this.

If the numbers are in plain-text, but at fixed column-offsets, I
usually create a mapping of slices to make it easier to work with.
If this is the case and you want some example code, I can dig some up.

Finally, if the data is actually binary, Python's "struct" module
(also in the standard library) makes it a lot easier to work with such
data.

-tkc





More information about the Python-list mailing list