{"id":26853,"library":"copybook","title":"copybook","description":"A Python library for parsing COBOL copybooks (data definition records). Current version 1.0.16. Development appears infrequent with no recent releases.","status":"active","version":"1.0.16","language":"python","source_language":"en","source_url":"https://github.com/zalmane/copybook","tags":["COBOL","copybook","parser","mainframe"],"install":[{"cmd":"pip install copybook","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Used for parsing copybook syntax","package":"pyparsing","optional":false}],"imports":[{"note":"Copybook is a class, not a module. Using import Copybook will fail.","wrong":"import Copybook","symbol":"Copybook","correct":"from copybook import Copybook"},{"note":"CopybookError is defined in __init__.py, not in a submodule.","wrong":"from copybook.errors import CopybookError","symbol":"CopybookError","correct":"from copybook import CopybookError"}],"quickstart":{"code":"from copybook import Copybook\n\ncb = Copybook('')\ncb.parse(\n    struct=\"\n        01 RECORD.\n           05 NAME    PIC X(30).\n           05 AGE     PIC 9(3).\n    \"\n)\nprint(cb.layout)\n# Example output: {'NAME': (1, 30), 'AGE': (31, 33)}","lang":"python","description":"Parse a COBOL copybook string and get field positions."},"warnings":[{"fix":"Use open('copybook.cbl').read() to get the content, then pass it to parse.","message":"The parse method does not accept file paths; you must read the copybook file yourself and pass the content as a string.","severity":"gotcha","affected_versions":"all"},{"fix":"When using layout offsets, remember that the first byte is 1. Adjust if your downstream expects 0-based.","message":"Copybook layout indices are 1-based, not 0-based.","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 'from copybook import Copybook'.","cause":"Trying to import Copybook directly without from syntax.","error":"AttributeError: module 'copybook' has no attribute 'Copybook'"},{"fix":"Simplify the copybook to only elementary items with PIC clauses. The library does not fully support complex COBOL.","cause":"Copybook contains unsupported COBOL constructs like OCCURS or REDEFINES.","error":"ParseError: Unexpected token"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}