Skip to content

Instantly share code, notes, and snippets.

@jjsahalf
Last active March 29, 2017 19:54
Show Gist options
  • Save jjsahalf/3cda19d657470ce3b2eaeba1e55ce089 to your computer and use it in GitHub Desktop.
Save jjsahalf/3cda19d657470ce3b2eaeba1e55ce089 to your computer and use it in GitHub Desktop.
Basic file open, read, write, replace operations.
import os, sys
os.system("find "+sys.argv[1]+" -type f > "+sys.argv[1]+"/namelist")
writeFile=open(sys.argv[1]+"/output", "w")
with open(sys.argv[1]+"/namelist") as f:
for line in f:
arr=line.split(".")
newLine=arr[1][1:]
newLine=newLine.replace("/", ".")
if newLine == "namelist":
continue
if newLine == "getClassList":
continue
writeFile.write(newLine+"\n")
print newLine
writeFile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment