'Reading a Cobol (.cbl) file in python and extract the commented lines from it
I am having a .cbl file with many lines. I want to read it and extract the commented lines form the same into a .txt file.
For example:
a. 000200* PROGRAM-ID. AP540P00.
(or)
b. * PROGRAM-ID. AP540P00.
I need to check for * at 7th position. After extracting all the commented lines print it to a text file.
I did this:
with open('AP540P00.cbl', 'r') as f:
for line in f:
s = set(line)
if ('*' in s ):
print(line)
But I need to specifically check * only at 7th index of every line.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
