0

I need to change a line in a text file based on a criteria. I am running the following script:

fh, newMapFullName = mkstemp()
newMapFile = open (newMapFullName, 'w')
oldMapFile = open(oldMapFullName)
pattern = 'PROCESSING "CHART_SIZE_RANGE='
substr= 'PROCESSING "CHART_SIZE_RANGE= {0} {1} {2} {3} {4}"'.format("sum_all", minPix, maxPix, oldMinSum, oldMaxSum)
for line in oldMapFile:
    if pattern in line:
        newMapFile.write(substr)
    else:
        newMapFile.write(line)

This script works as intended, but changes the file permissions. I can only open the file if done from the command prompt as an administrator. I am running python 2.7 on Windows. This response suggests this is possible with os.chmod, which isn't available on Windows. Is there an equivalent process that would work?

Community
  • 1
  • 1
Jason Hawkins
  • 625
  • 1
  • 9
  • 24
  • possible duplicate of [Setting folder permissions in Windows using Python](http://stackoverflow.com/questions/12168110/setting-folder-permissions-in-windows-using-python) – hlt Aug 18 '14 at 22:22
  • Duplicate, but other post solved my problem. – Jason Hawkins Aug 18 '14 at 22:54

0 Answers0