Skip to main content

Mimics Fortran textual IO in Python

Project description

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'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fortranformat-0.2.3.tar.gz (18.6 kB view details)

Uploaded Source

File details

Details for the file fortranformat-0.2.3.tar.gz.

File metadata

File hashes

Hashes for fortranformat-0.2.3.tar.gz
Algorithm Hash digest
SHA256 ec76c1c7bc07972aa98e01ff2303bb0aefe77306be8ff2723bc40b7c7775292c
MD5 d78c5a320fedcbdf21f823cd18e28ac0
BLAKE2b-256 8408ad5f5ba86f132e26dbe69d213ae0e45af2d2959fb7f88a59afceb67ba6f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page