-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataPreparation.py
More file actions
29 lines (21 loc) · 975 Bytes
/
DataPreparation.py
File metadata and controls
29 lines (21 loc) · 975 Bytes
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
import csv
import facebook
import requests
import traceback
import sys
import glob
import shutil
par_dir = "C:\\Users\\apoorva\\Desktop\\WINTER QUARTER\\Machine Learning\\Project\\"
img_dir_Train = par_dir+"FacebookDataTCSS555Project\\TCSS555\\Train\\Image\\*.jpg"
destination_directory = par_dir + "FacebookDataTCSS555Project\\TCSS555\\Train\\Image\\Renamed\\"
count = 0
for fileName in glob.glob(img_dir_Train):
with open('Profile.csv', 'r') as profileFile:
profileReader = csv.DictReader(profileFile)
for profileRow in profileReader:
if fileName.split('\\')[-1].split('.')[0] == profileRow['userid']:
value = "Female" if profileRow['gender'] == "1.0" else "Male"
destination_file = destination_directory + value + '_' + profileRow['age'] + '_' + str(count) + ".jpg"
shutil.copy(fileName, destination_file)
count += 1
break