@@ -15,9 +15,119 @@ The **COBOL-to-Python Converter** is a utility tool that converts COBOL source c
15
15
16
16
## Getting Started
17
17
18
- ### Prerequisites
18
+ ### Cloning the Repository
19
19
20
- - Python 3.8 or later
21
- - A valid COBOL source code file
20
+ Clone this repository using the following command:
22
21
23
- ---
22
+ ``` bash
23
+ git clone https://github.com/Cod-e-Codes/cobol-to-python.git
24
+ cd cobol-to-python
25
+ ```
26
+
27
+ ### Usage
28
+
29
+ To convert a COBOL file to Python:
30
+
31
+ ``` bash
32
+ python cobol_converter.py < input_cobol_file> < output_python_file>
33
+ ```
34
+
35
+ #### Example:
36
+ ``` bash
37
+ python cobol_converter.py payroll_system.cob payroll_system.py
38
+ ```
39
+
40
+ This command will generate ` payroll_system.py ` with Python code translated from ` payroll_system.cob ` .
41
+
42
+ ---
43
+
44
+ ## Input Data Format
45
+
46
+ The converter assumes specific field layouts for COBOL records. Below is the expected input data format for the ` employees.dat ` file:
47
+
48
+ | ** Field** | ** Length (Chars)** | ** Position** |
49
+ | ------------------| --------------------| --------------|
50
+ | Employee ID | 5 | 0-4 |
51
+ | Space | 1 | 5 |
52
+ | Employee Name | 20 | 6-25 |
53
+ | Space | 1 | 26 |
54
+ | Department | 19 | 27-45 |
55
+ | Space | 1 | 46 |
56
+ | Salary | 8 | 47-54 |
57
+ | Space | 1 | 55 |
58
+ | Tax Rate | 5 | 56-60 |
59
+
60
+ ---
61
+
62
+ ### Output Example
63
+
64
+ For a COBOL input program like this:
65
+
66
+ ``` cobol
67
+ IDENTIFICATION DIVISION.
68
+ PROGRAM-ID. PAYROLL-SYSTEM.
69
+ ...
70
+ ```
71
+
72
+ The converter generates Python code like:
73
+
74
+ ``` python
75
+ import decimal
76
+
77
+ class PAYROLL_SYSTEM :
78
+ class EMPLOYEERecord :
79
+ def __init__ (self ):
80
+ self .emp_id = 0
81
+ self .emp_name = " "
82
+ self .emp_department = " "
83
+ self .emp_salary = 0.0
84
+ self .emp_tax_rate = 0.0
85
+
86
+ def __init__ (self ):
87
+ self .employee_file_path = ' employees.dat'
88
+ ...
89
+ ```
90
+
91
+ ---
92
+
93
+ ### Running the Generated Script
94
+
95
+ After generating the Python script, run it with:
96
+
97
+ ``` bash
98
+ python < output_python_file>
99
+ ```
100
+
101
+ Example:
102
+ ``` bash
103
+ python payroll_system.py
104
+ ```
105
+
106
+ Ensure the input data file (` employees.dat ` ) exists in the same directory as the script.
107
+
108
+ ---
109
+
110
+ ## Contributing
111
+
112
+ Contributions are welcome! If you find any issues or have suggestions for improvement, please create an issue or submit a pull request.
113
+
114
+ ---
115
+
116
+ ## License
117
+
118
+ This project is licensed under the [ MIT License] ( LICENSE ) .
119
+
120
+ ---
121
+
122
+ ## Author
123
+
124
+ ** CodēCodes**
125
+ GitHub: [ Cod-e-Codes] ( https://github.com/Cod-e-Codes )
126
+
127
+ ---
128
+
129
+ ### Future Enhancements
130
+
131
+ - Add support for more COBOL constructs.
132
+ - Include unit tests for the converted Python code.
133
+ - Enhance error handling during conversion.
0 commit comments