-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcsvtest.py
28 lines (27 loc) · 1.05 KB
/
csvtest.py
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
import csv
import zipfile
import glob
zip_ref = zipfile.ZipFile('all_zeros_benchmark.zip', 'r')
zip_ref.extractall("Downloads")
zip_ref.close()
imagelist2 = []
zip_ref2 = zipfile.ZipFile('images_test_rev1.zip', 'r')
zip_ref2.extractall("Downloads")
zip_ref2.close()
count = 1
for file2 in glob.glob("Downloads\images_test_rev1\*.jpg"):
imagelist2.append(file2[27:33])
counter = 0
with open('testzeros.csv', 'w') as csvfile:
writer = csv.writer(csvfile, delimiter=' ',
quotechar='', quoting=csv.QUOTE_NONE, escapechar='\\')
with open('Downloads/all_zeros_benchmark.csv') as f:
reader = csv.reader(f) # read rows into a dictionary format
for row in reader: # read a row as {column1: value1, column2: value2,...}
if counter == 0:
writer.writerow([','.join(row)])
counter+= 1
for i in range(len(imagelist2)):
for j in range(37):
imagelist2[i] = imagelist2[i]+',0'
writer.writerow([str(imagelist2[i])])