Skip to main content

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

Project description

Fortio

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

Features

  • 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

Installation

pip install fortio

Usage

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

Functions

  • 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

0.4

Download files

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

Source Distribution

fortio-0.4.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

fortio-0.4-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file fortio-0.4.tar.gz.

File metadata

  • Download URL: fortio-0.4.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for fortio-0.4.tar.gz
Algorithm Hash digest
SHA256 e143fbb8cc2644550b3b08ecef62eae190daf82377b5527a68d04037be934650
MD5 be9803d9c5619604202e1517471ea72a
BLAKE2b-256 68256504a059363ea7a31e2ceadb2d096c571803f9bb43c257f0fe9ebc2276d5

See more details on using hashes here.

File details

Details for the file fortio-0.4-py3-none-any.whl.

File metadata

  • Download URL: fortio-0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for fortio-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bd851a3ee5a59ed61343212506b3c7d29c4c9934a79002c063a1311882718ec5
MD5 31f66481413ff9711c1468dfa6f70410
BLAKE2b-256 2375adf609fa59c4329ac361aee82c17cc86de7b93b3098e84d3dc2dd6ac9b10

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