Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions csv2dict/Csv2Dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Csv2Dict:



def __init__(self, data_file, sheet, blankout=False):
def __init__(self, data_file, sheet, nx, blankout=False):
'''
The Csv2Dict class reads a csv data file, the first line of which contains column names. Succeeding
lines represent rows of data. Initially the column names are used as the keys to a list of dicts, one
Expand All @@ -39,7 +39,8 @@ def __init__(self, data_file, sheet, blankout=False):
self.meta_dicts = []
self.blankout = blankout
self.sheet = sheet
self.data = None
self.nx = nx
self.data = {}

self.meta_dict_properties_template = {}

Expand Down Expand Up @@ -136,10 +137,9 @@ def get_existing_data(self, filepath, metadata_path):
if self.blankout == True:
return []
else:
if self.data == None:
nx = utils.Nuxeo()
self.data = nx.get_metadata(path=filepath)
return self.data['properties']['ucldc_schema:{}'.format(metadata_path)]
if self.data.get(filepath, None) == None:
self.data[filepath] = self.nx.get_metadata(path=filepath)
return self.data[filepath]['properties']['ucldc_schema:{}'.format(metadata_path)]

def set_list_element(self, metadata_path, row_title, row, n):
filepath = row['File path']
Expand Down
2 changes: 1 addition & 1 deletion csv2dict/meta_from_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def main(argv):
# get and instance of the Csv2Dict class which must be initialized
# with the name of an input data (csv) file

csv2dict = Csv2Dict(csv_data_file, blankout=args.blankout, sheet=args.sheet)
csv2dict = Csv2Dict(csv_data_file, blankout=args.blankout, sheet=args.sheet, nx=nx)

if csv2dict.status != 0:
print('The Csv2Dict constructor reported and error (%d).' % csv2dict.status)
Expand Down