Skip to main content

A Python IO for Fortran unformatted binary files with variable-length records.

Project description


A Python IO for Fortran Unformatted Binary Files with Variable-Length Records.


  • read and write Fortran unformatted file
  • auto-detect endianness(byteorder)
  • allow reading data into pre-allocated buffers
  • allow skipping over records or jumping to wanted record directly without reading data
  • support subrecords (which is necessary for long record whose size larger than 4GB with signed 4 bytes integer header)
  • support numpy.memmap array for fast loading


pip install fortio


from fortio import FortranFile
with FortranFile(filename) as f:
    a = f.read_record('i4')
    b = f.read_record('f8')


  • FortranFile(filename, mode='r', header_dtype='uint32', auto_endian=True, check_file=True)

  • methods

    • write_record(data)
    • read_record(dtype='byte', shape=None, rec=None, memmap=False)
    • mmap_record(dtype='byte', shape=None, rec=None)
    • read_record_into(into, offset=None, rec=None)
    • get_record_size(rec=None)
    • skip_record(nrec=1)
    • goto_record(rec=None)
    • close()
    • flush()
  • properties

    • file
    • filesize
    • mode
    • header_dtype
    • long_records
    • closed
    • byteorder
  • internal properties and methods

    • _fp
    • _offsets
    • _lengths
    • _read_header()
    • _check_byteorder()
    • _check_file()
    • _read_record_data(data)

Project details

Release history Release notifications | RSS feed

This version


Download files

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

Files for fortio, version 0.4
Filename, size File type Python version Upload date Hashes
Filename, size fortio-0.4-py3-none-any.whl (12.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size fortio-0.4.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page