{"id":19264182,"url":"https://github.com/cphyc/cython_fortran_file","last_synced_at":"2025-04-21T18:31:54.062Z","repository":{"id":32324284,"uuid":"132256152","full_name":"cphyc/cython_fortran_file","owner":"cphyc","description":"An efficient package to read fortran-record files in Python","archived":false,"fork":false,"pushed_at":"2025-04-08T08:07:21.000Z","size":240,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T09:25:34.628Z","etag":null,"topics":["cython-fortran","fortran","python"],"latest_commit_sha":null,"homepage":null,"language":"Cython","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cphyc.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-05T14:39:30.000Z","updated_at":"2025-04-08T08:07:17.000Z","dependencies_parsed_at":"2023-10-03T13:52:36.328Z","dependency_job_id":"31668249-7c18-46c3-9de7-a91decc9d987","html_url":"https://github.com/cphyc/cython_fortran_file","commit_stats":{"total_commits":141,"total_committers":4,"mean_commits":35.25,"dds":0.6950354609929078,"last_synced_commit":"a2be799260078caf25e6afe013df3c6fdce68df7"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fcython_fortran_file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fcython_fortran_file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fcython_fortran_file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fcython_fortran_file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cphyc","download_url":"https://codeload.github.com/cphyc/cython_fortran_file/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250111075,"owners_count":21376585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cython-fortran","fortran","python"],"created_at":"2024-11-09T19:40:08.787Z","updated_at":"2025-04-21T18:31:53.713Z","avatar_url":"https://github.com/cphyc.png","language":"Cython","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cython fortran-file\n\n[![Build and Test](https://github.com/cphyc/cython_fortran_file/actions/workflows/build-test.yaml/badge.svg)](https://github.com/cphyc/cython_fortran_file/actions/workflows/build-test.yaml)\n[![PyPI](https://img.shields.io/pypi/v/cython_fortran_file)](https://pypi.org/project/cython_fortran_file)\n[![Conda-forge](https://img.shields.io/conda/vn/conda-forge/cython-fortran-file.svg)](https://anaconda.org/conda-forge/cython-fortran-file)\n\nThis package is a fast and easy reader for record-based binary format, as written by Fortran.\n\n## Installation\n\nThis packages requires a compiler to be installed on you system. If you're using Linux or MacOSX you should be fine. If you're using Windows, please get in touch with me or open an issue.\n```\npip install cython_fortran_file\n```\nThat's all!\n\n## Using it\nHere is a simple demonstration:\n\n```python\nfrom cython_fortran_file import FortranFile as FF\n\nf = FF(\"/path/to/my/fortran/file.dat\", mode=\"r\")\n\n# Skip 5 records\nf.skip(5)\n\n# Read one record (an array of `double`)\ndata = f.read_vector(\"d\")\nassert data.dtype == np.float64\n\n# Read one record (an array of signed `int`)\ndata = f.read_vector(\"i\")\nassert data.dtype == np.int32\n\n# Read one *single* int. This will fail if there is more to read!\nv = f.read_int()\n\n# f _looks_ like a regular file descriptor\nf.tell()\nf.seek(0)\nf.close()\n```\n\nIt also supports `with` statement so that you can't forget to close the file handler\n```python\nwith FF(\"/path/to/my/fortran/file.dat\") as f:\n    f.skip(5)\n\n    data = f.read_vector(\"d\")  # Read a vector of doubles (as usual)\n```\n\n## Data types\n\nThe argument of `read_vector` follows the convention of the python struct package (C convention). See https://docs.python.org/3.5/library/struct.html#format-characters for the full list. Here is a shorter version:\n\nArgument | Fortran type | C type     | Numpy dtype\n---------|--------------|------------|--------------\n`d`      | `real(8)`    | `double`   | `np.float64`\n`f`      | `real(4)`    | `float`    | `np.float32`\n`i`      | `integer`    | `int`      | `np.int32`\n`l`      | `integer(8)` | `long`     | `np.int64`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcphyc%2Fcython_fortran_file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcphyc%2Fcython_fortran_file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcphyc%2Fcython_fortran_file/lists"}