Skip to content

Commit 32f5f60

Browse files
committed
updates
1 parent d10398c commit 32f5f60

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

samplingScript.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import csv
55
from datetime import datetime
6+
import itertools
67

78
filePath = raw_input('Enter file path (C:/Test/): ')
89

@@ -11,33 +12,29 @@
1112
f2=csv.writer(open('unsampledLog'+datetime.now().strftime('%Y-%m-%d %H.%M.%S')+'.csv','wb'))
1213
f2.writerow(['oldLocation']+['newLocation'])
1314

14-
print filePath
15-
1615
for root, dirs, files in os.walk(filePath, topdown=True):
1716
print root
18-
number = 1
19-
while number < len(files):
20-
oldLocation = os.path.join(root, files[number])
17+
print files
18+
sampledFiles = itertools.islice(files, 1, None, 10)
19+
for sampledFile in sampledFiles:
20+
print sampledFile
21+
oldLocation = os.path.join(root, sampledFile)
2122
project = root[root.rfind('/')+1:]
2223
root1 = root[:root.rfind('/')]
2324
root2 = root1[:root1.rfind('/')]
2425
newLocation = os.path.join(root2, 'sampled', project)
2526
if not os.path.exists(newLocation):
26-
os.makedirs(newLocation)
27-
print newLocation
28-
newLocation = os.path.join(newLocation, files[number])
27+
os.makedirs(newLocation)
28+
newLocation = os.path.join(newLocation, sampledFile)
2929
print oldLocation
3030
print newLocation
3131
f.writerow([oldLocation]+[newLocation])
32-
number = number + 10
3332
shutil.move(oldLocation, newLocation)
3433
oldUnsampledLocation = os.path.join(root)
3534
if oldUnsampledLocation != filePath:
3635
project = root[root.rfind('/')+1:]
3736
root1 = root[:root.rfind('/')]
3837
root2 = root1[:root1.rfind('/')]
3938
newUnsampledLocation = os.path.join(root2, 'unsampled', project)
40-
print oldUnsampledLocation
41-
print newUnsampledLocation
4239
f2.writerow([oldUnsampledLocation]+[newUnsampledLocation])
4340
shutil.move(oldUnsampledLocation, newUnsampledLocation)

0 commit comments

Comments
 (0)