{"id":23900724,"url":"https://github.com/cod-e-codes/cobol-to-python","last_synced_at":"2025-02-23T09:42:52.195Z","repository":{"id":267823260,"uuid":"902468729","full_name":"Cod-e-Codes/cobol-to-python","owner":"Cod-e-Codes","description":"A tool to convert COBOL to Python, enabling seamless modernization of legacy systems with structured, functional Python code.","archived":false,"fork":false,"pushed_at":"2024-12-12T17:52:39.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T20:42:33.864Z","etag":null,"topics":["cobol","code-conversion","legacy-code","migration","modernization","python","utility-tool"],"latest_commit_sha":null,"homepage":"https://github.com/Cod-e-Codes/cobol-to-python","language":"Python","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/Cod-e-Codes.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":"2024-12-12T16:16:15.000Z","updated_at":"2024-12-16T00:16:01.000Z","dependencies_parsed_at":"2024-12-12T17:31:08.277Z","dependency_job_id":"72a92362-8e39-4583-b0f3-b36f416bedec","html_url":"https://github.com/Cod-e-Codes/cobol-to-python","commit_stats":null,"previous_names":["cod-e-codes/cobol-to-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2Fcobol-to-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2Fcobol-to-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2Fcobol-to-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cod-e-Codes%2Fcobol-to-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cod-e-Codes","download_url":"https://codeload.github.com/Cod-e-Codes/cobol-to-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240298398,"owners_count":19779280,"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":["cobol","code-conversion","legacy-code","migration","modernization","python","utility-tool"],"created_at":"2025-01-04T20:36:58.588Z","updated_at":"2025-02-23T09:42:52.133Z","avatar_url":"https://github.com/Cod-e-Codes.png","language":"Python","readme":"# COBOL-to-Python Converter\n\nThe **COBOL-to-Python Converter** is a utility tool that converts COBOL source code into Python. This tool aims to simplify the process of migrating legacy COBOL applications to modern Python-based systems, while also generating Python code that adheres to the functional structure of the original COBOL program.\n\n---\n\n## Features\n\n- **Automatic Translation**: Converts COBOL code, including variable declarations, records, and procedures, into Python classes and methods.\n- **File Parsing**: Supports parsing file assignments and generates Python code with proper file handling.\n- **Customizable Parsing Rules**: Leverages regex patterns to interpret COBOL structures like `WORKING-STORAGE` and `PROCEDURE DIVISION`.\n- **Detailed Output**: Generates Python scripts with the corresponding logic based on COBOL field lengths and offsets.\n\n---\n\n## Getting Started\n\n### Prerequisites\n\n- Python 3.7 or higher installed on your system. You can download it [here](https://www.python.org/downloads/).\n- Basic knowledge of running Python scripts via the command line.\n\n### Installation\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/Cod-e-Codes/cobol-to-python.git\n    cd cobol-to-python\n    ```\n\n2. No additional installations are required for this project.\n\n### Usage\n\nTo convert a COBOL file to Python:\n\n```bash\npython cobol_converter.py \u003cinput_cobol_file\u003e \u003coutput_python_file\u003e\n```\n\n#### Example:\n```bash\npython cobol_converter.py payroll_system.cob payroll_system.py\n```\n\nThis command will generate `payroll_system.py` with Python code translated from `payroll_system.cob`.\n\n---\n\n## Input Data Format\n\nThe converter assumes specific field layouts for COBOL records. Below is the expected input data format for the `employees.dat` file:\n\n| **Field**       | **Length (Chars)** | **Position** |\n|------------------|--------------------|--------------|\n| Employee ID      | 5                 | 0-4          |\n| Space            | 1                 | 5            |\n| Employee Name    | 20                | 6-25         |\n| Space            | 1                 | 26           |\n| Department       | 19                | 27-45        |\n| Space            | 1                 | 46           |\n| Salary           | 8                 | 47-54        |\n| Space            | 1                 | 55           |\n| Tax Rate         | 5                 | 56-60        |\n\n---\n\n### Output Example\n\nFor a COBOL input program like this:\n\n```cobol\nIDENTIFICATION DIVISION.\nPROGRAM-ID. PAYROLL-SYSTEM.\n...\n```\n\nThe converter generates Python code like:\n\n```python\nimport decimal\n\nclass PAYROLL_SYSTEM:\n    class EMPLOYEERecord:\n        def __init__(self):\n            self.emp_id = 0\n            self.emp_name = \"\"\n            self.emp_department = \"\"\n            self.emp_salary = 0.0\n            self.emp_tax_rate = 0.0\n\n    def __init__(self):\n        self.employee_file_path = 'employees.dat'\n        ...\n```\n\n---\n\n### Running the Generated Script\n\nAfter generating the Python script, run it with:\n\n```bash\npython \u003coutput_python_file\u003e\n```\n\nExample:\n```bash\npython payroll_system.py\n```\n\nEnsure the input data file (`employees.dat`) exists in the same directory as the script.\n\n---\n\n## Contributing\n\nContributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or submit a pull request.\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n---\n\n## Author\n\n**CodēCodes**  \nGitHub: [Cod-e-Codes](https://github.com/Cod-e-Codes)\n\n---\n\n### Future Enhancements\n\n- Add support for more COBOL constructs.\n- Include unit tests for the converted Python code.\n- Enhance error handling during conversion.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcod-e-codes%2Fcobol-to-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcod-e-codes%2Fcobol-to-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcod-e-codes%2Fcobol-to-python/lists"}