I am trying to learn Python by converting my C++ homework to Python. Below I am converting a Cobol file of employees to a comma delimited file.
from:
00001JAMES ADAMSON 010104000014550324201021500067500040010011593
to:
ID#,Last,First,Territory#,Office#,Salary,SSN,Department#,JobClass
00001,ADAMSON,JAMES,01,01,40000.00,145503242,01,02
I want to use EOF as my while loop control but I am getting a syntax error. Am I heading down the right path? Is there a better way to write this code? Any help would be great! Also this is my first posting about code, so if my format can be improved in any way, help here would be great too. Thanx in advance!
Lanier
fName=open('H:/CSC/Programs/CobolTran/Empcobol.dat')
WriteToo=open('H:/CSC/Employee.dat','w')
Trash='Start'
while Trash != EOF
ID=fName.read(5)
FullName=fName.read(26)
Territory=fName.read(2)
Office=fName.read(2)
Salary=fName.read(6)
SSN=fName.read(9)
Dep=fName.read(2)
JClass=fName.read(2)
Trash=fName.readline()
WriteToo.write(ID ','FullName','Territory',')