-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean_SBD_aggregatedFiles.py
More file actions
55 lines (36 loc) · 1.2 KB
/
Copy pathclean_SBD_aggregatedFiles.py
File metadata and controls
55 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/env python
# -*- coding: utf-8 -*-
import os
class cleaningNC:
def __init__(self):
"""
cleanout *.nc files from folders in supplied parent folder
The first level of folders are to be checked ignoreing sub folders called profiles
"""
self.cleanedCount = 0;
self.status = []
self.errorFiles = []
def processFiles(self,origDir):
self.sbddataFolder = origDir
os.chdir(origDir)
for root, dirs, fname in os.walk(os.getcwd()):
fname.sort()
for fname in fname:
if fname.rsplit(".",1)[1] == "nc":
# ignore profiles directories
if (root[-9:] != "/profiles"):
self.handleFiles(root,fname)
def handleFiles(self,root, fname):
theFile = root+"/"+fname
try:
os.remove(theFile)
except Exception, e:
print "ERROR: Failed to remove " + theFile
try:
open(theFile)
print "failed to remove " + theFile
except Exception, e:
print "Removed: " + theFile
if __name__ == "__main__":
f = cleaningNC()
#f.processFiles("/home/smancini/datafabric_root/opendap/AATAMS/sattag")