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.

The following is a quistart, full docs are found at the project page wiki!.

To read Fortran records,:

>>> import fortranformat as ff
>>> header_line = ff.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,:

>>> import fortranformat as ff
>>> header_line = ff.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.5.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

fortranformat-0.2.5.win-amd64.exe (248.3 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for fortranformat-0.2.5.tar.gz
Algorithm Hash digest
SHA256 6b5fbc1f129c7a70543c3a81f334fb4d57f07df2834b22ce69f6d7e8539cd3f9
MD5 3b8cd134f1c2cb02a7a1119a086ea7f6
BLAKE2b-256 7f8a5c2361b8a45238f593ef4824b24f2dd122dd3294297424aa37486de08209

See more details on using hashes here.

File details

Details for the file fortranformat-0.2.5.win-amd64.exe.

File metadata

File hashes

Hashes for fortranformat-0.2.5.win-amd64.exe
Algorithm Hash digest
SHA256 03f7eb86d612cef3aa959d73d3f449a53f257f1357e3195d00f92dec9c083294
MD5 8637e63f9366d9e943ff3a7ad6cf43f0
BLAKE2b-256 4d2639c8e03088b970d437237e1a9ee30c2ad5e88c4665cbee0de119b54509a6

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