-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCatalog_compiler.py
More file actions
32 lines (31 loc) · 1.19 KB
/
Catalog_compiler.py
File metadata and controls
32 lines (31 loc) · 1.19 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
import numpy as np
import pandas as pd
from glob import glob
import os
import csv
def Join_searches(Path,Save):
camps = glob(path + '*/')
for camp in camps:
files = glob(camp + '*.csv')
savename = Save + 'NED_' + files[0].split('_')[2] + '.csv'
objects = set([])
for file in files:
print(file)
dataframe = pd.read_csv(file)
data = dataframe.values
for row in data:
if row[2] not in objects:
objects.add(row[2])
if os.path.isfile(savename):
with open(savename, 'a') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',')
spamwriter.writerow(row[2:])
else:
with open(savename, 'w') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',')
spamwriter.writerow(dataframe.keys()[2:])
spamwriter.writerow(row[2:])
else:
pass
print('Done NED cat for C' + files[0].split('_')[2])
return objects, 'Done NED'