On Thursday, 18 February 2016 21:31:20 UTC+2, Tim Chase wrote: > On 2016-02-18 07:33, wrong.addres...@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
Thanks. The data I will often have to read from text files could read like 2 12.657823 0.1823467E-04 114 0 3 4 5 9 11 "Lower" 278.15 Is it straightforward to read this, or does one have to read one character at a time and then figure out what the numbers are? -- https://mail.python.org/mailman/listinfo/python-list