please bare with me as im a returning newbie and have not really used re.expression much and still get very confused!
i am currently working on a few database records which need appending.
this is one of the files i need to resort
the data base has now changed and i need to strip the first two sections and replace with lower case ie..
would now be
this is the text file i have
and so on for about another 3000 odd lines
i can search though the whole file and remove all upper case text but i need the upper case on everything apart from the first to sections but as it only has two capitals and the rest are numbers im stuck on which way i should do it.
import sys import string import pprint import re newlist=() inFile = open('Person_Staff.txt','r') s = inFile.read() oldStr = ("E.......") newStr = ("e.......") inFile.close() oldlist = re.compile('oldStr').match('inFile', 1) newlist=(str.replace(oldStr, newStr, oldlist)) outFile = open('Person_Staff.txt','w') outFile.write(newlist) outFile.close() print(newlist)
this is what i have got so far but this just returns errors and i am not shore what to do next or what i haven't done yet!
any help and suggestions would be very helpful!