fortranformat 0.2.3
Mimics Fortran textual IO in Python
Generates text from a Python list of variables or will read a line of text into Python variables according to the FORTRAN format statement passed.
Licensed under the MIT license
The library is extensively unit-tested (but not yet extensively user-tested, please report bugs!) against the Intel FORTRAN compiler on a Linux platform. Differences between platforms/compilers are generally minor.
To read Fortran records,:
>>> from fortranformat import FortranRecordReader
>>> header_line = FortranRecordReader('(A15, A15, A15)')
>>> header_line.read(' x y z')
[' x', ' y', ' z']
>>> line = FortranRecordReader('(3F15.3)')
>>> line.read(' 1.000 0.000 0.500')
[1.0, 0.0, 0.5]
>>> line.read(' 1.100 0.100 0.600')
[1.1, 0.1, 0.6]
To write Fortran records,:
>>> from fortranformat import FortranRecordWriter
>>> header_line = FortranRecordWriter('(A15, A15, A15)')
>>> header_line.write(['x', 'y', 'z'])
' x y z'
>>> line = FortranRecordWriter('(3F15.3)')
>>> line.write([1.0, 0.0, 0.5])
' 1.000 0.000 0.500'
>>> line.write([1.1, 0.1, 0.6])
' 1.100 0.100 0.600'
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| fortranformat-0.2.3.tar.gz (md5) | Source | 2011-09-08 | 18KB | 298 | |
- Author: Brendan Arnold
- Home Page: http://bitbucket.org/brendanarnold/py-fortranformat
- Download URL: https://bitbucket.org/brendanarnold/py-fortranformat/downloads/fortranformat-0.2.3.tar.gz
- Keywords: fortran,io,interface,format
-
Categories
- Development Status :: 4 - Beta
- Environment :: Console
- Intended Audience :: Developers
- Intended Audience :: Science/Research
- License :: OSI Approved :: MIT License
- Natural Language :: English
- Operating System :: OS Independent
- Programming Language :: Fortran
- Programming Language :: Python :: 2
- Programming Language :: Python :: 3
- Topic :: Scientific/Engineering
- Topic :: Software Development :: Interpreters
- Topic :: Text Processing :: General
- Package Index Owner: brendanarnold
- DOAP record: fortranformat-0.2.3.xml
