{"id":24522,"library":"resfo","title":"Reservoir Fortran Output","description":"A lazy parser and writer for reservoir simulator Fortran output format (unformatted and formatted). Current version 5.0.1 with strict typing and type stubs. Maintenance via Equinor, release cadence irregular.","status":"active","version":"5.0.1","language":"python","source_language":"en","source_url":"https://github.com/equinor/resfo","tags":["reservoir-simulation","fortran","parser","lazy","eclipse"],"install":[{"cmd":"pip install resfo","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"lazy_read is a top-level function, not a submodule.","wrong":"from resfo.lazy_read import ...","symbol":"lazy_read","correct":"from resfo import lazy_read"},{"note":"read is also top-level, but lazy_read is preferred for large files.","wrong":"import resfo; resfo.read()","symbol":"read","correct":"from resfo import read"},{"note":"write is top-level; arguments changed in v5: no longer accepts dict for data.","wrong":"","symbol":"write","correct":"from resfo import write"},{"note":"Enum for FORMATTED/UNFORMATTED file format.","wrong":"","symbol":"Format","correct":"from resfo import Format"},{"note":"TypedDict representing a single keyword entry.","wrong":"","symbol":"Entry","correct":"from resfo import Entry"}],"quickstart":{"code":"from resfo import lazy_read, Format\n\n# Path to a small .FEGRID file\nfilepath = 'sample.FEGRID'  # replace with actual path\nfor entry in lazy_read(filepath, fileformat=Format.UNFORMATTED):\n    print(f\"Keyword: {entry.keyword}, Size: {len(entry.data)}\")","lang":"python","description":"Lazily read an unformatted reservoir output file and print each keyword name and data size."},"warnings":[{"fix":"Replace dict with a list of Entry objects: write(filename, [Entry('KEYWORD', numpy_array)], fileformat=Format.FORMATTED)","message":"In version 5.0.0, write() no longer accepts a dict for the data argument. Use a list of Entry objects instead.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"If you need random access, use read() instead, which reads all entries into memory.","message":"lazy_read returns an iterator, not a list. It reads data lazily; iterating multiple times will reset the file pointer or raise a StopIteration.","severity":"gotcha","affected_versions":"all"},{"fix":"Use a list of Entry objects: from resfo import Entry; write('file', [Entry('KEY', np.array([1,2]))])","message":"Passing a dict to write() is removed in v5. The old pattern write('file', {'KEY': [1,2]}) no longer works.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Always iterate fully or use a context manager if available (not yet, but wrap in try/finally).","message":"Memory usage: lazy_read keeps only one entry in memory at a time, but the iterator must be consumed completely. If you stop early, the file handle may not be closed immediately.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use write(filename, data, fileformat=Format.FORMATTED) instead of positional.","cause":"In older versions, fileformat was a positional argument; in v5 it is a keyword-only argument.","error":"TypeError: write() got an unexpected keyword argument 'fileformat'"},{"fix":"Use 'from resfo import lazy_read'.","cause":"lazy_read is a function, not a submodule; incorrect import path.","error":"ModuleNotFoundError: No module named 'resfo.lazy_read'"},{"fix":"Construct a list of Entry objects with keyword and data (numpy array).","cause":"Version 5 no longer accepts dict for write(). Data must be a list/tuple of Entry.","error":"ValueError: data parameter must be an iterable of Entry objects, not dict"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}