/CodeMigrate

๐Ÿš€ CodeMigrate is a COBOL-to-Python converter designed to help modernize legacy enterprise applications. Built with Python, it supports COBOL structure parsing, file I/O migration, and output-ready Python scripts.

Primary LanguagePythonMIT LicenseMIT

๐Ÿ› ๏ธ CodeMigrate โ€“ Modernize COBOL in a Click! ๐Ÿโœจ

A lightning-fast COBOL โžœ Python converter built with โค๏ธ in pure Python.

GitHub Repo stars GitHub last commit Built with


๐ŸŒŸ Overview

CodeMigrate is a utility that translates legacy COBOL programs into clean, ready-to-run Python.
Ideal for teams moving main-frame logic to modern stacks without losing decades of business rules.


๐ŸŽจ Features

  • โšก Automatic Translation  โ€”  WORKING-STORAGE โžœ Python classes, PROCEDURE DIVISION โžœ functions
  • ๐Ÿ“‚ File Parsing  โ€”  Converts COBOL file I/O to Python file handling
  • ๐Ÿ” Regex-Driven Rules  โ€”  Easily extend patterns for custom COBOL syntax
  • ๐Ÿ“ Human-Readable Output  โ€”  Well-structured, commented Python code

๐Ÿ“‚ Project Structure

CodeMigrate/
โ”œโ”€โ”€ cobol_converter.py      # Main converter script
โ”œโ”€โ”€ payroll_system.cob      # Sample COBOL program
โ”œโ”€โ”€ employees.dat           # Sample data file
โ”œโ”€โ”€ payroll_system.py       # Generated sample output
โ”œโ”€โ”€ README.md               # This file
โ””โ”€โ”€ LICENSE                 # MIT

๐Ÿš€ Getting Started

๐Ÿ“ฆ Prerequisites

Python 3.7 +

๐Ÿ”ง Installation

git clone https://github.com/Shristirajpoot/CodeMigrate.git
cd CodeMigrate

(No extra packages required.)

โ–ถ๏ธ Convert a File

python cobol_converter.py payroll_system.cob payroll_system.py

โ–ถ๏ธ Run the Generated Script

python payroll_system.py

Ensure employees.dat is in the same directory.

๐Ÿ”ข Input Data Layout (employees.dat)

Field Length Offset
Employee ID 5 0โ€“4
Employee Name 20 6โ€“25
Department 19 27โ€“45
Salary 8 47โ€“54
Tax Rate 5 56โ€“60

Output Example

COBOL Snippet

IDENTIFICATION DIVISION.
PROGRAM-ID. PAYROLL-SYSTEM.
...

Auto-generated Python

import decimal

class PAYROLL_SYSTEM:
    class EMPLOYEERecord:
        def __init__(self):
            self.emp_id = 0
            self.emp_name = ""
            self.emp_department = ""
            self.emp_salary = 0.0
            self.emp_tax_rate = 0.0

    def __init__(self):
        self.employee_file_path = 'employees.dat'
        ...

Ensure the input data file (employees.dat) exists in the same directory as the script.


๐Ÿ“ˆ Roadmap / Future Enhancements

  • ๐Ÿš€ Support additional COBOL constructs (PERFORM, EVALUATE, etc.)

  • ๐Ÿงช Add unit-test scaffolding for generated code

  • ๐Ÿ›ก๏ธ Improve error handling & logging

๐Ÿค Contributing

  1. Fork the repo ๐Ÿก†

  2. git checkout -b feature/awesome

  3. Commit & push, then open a PR!

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Shristi Rajpoot

๐Ÿ“„ License

CodeMigrate is released under the MIT License.

โญ If this project saved you hours of manual migration, please star it and share!