|
|
@ -380,11 +380,16 @@ class Parser (Process):
|
|
|
|
value[label] = tmp if label not in value else value[label] + tmp
|
|
|
|
value[label] = tmp if label not in value else value[label] + tmp
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if label not in value:
|
|
|
|
# if 'DTM' in row :
|
|
|
|
|
|
|
|
# print ([label,tmp,label in value])
|
|
|
|
value[label] = [tmp]
|
|
|
|
if label not in value :
|
|
|
|
else:
|
|
|
|
value[label] = []
|
|
|
|
value[label].append(tmp)
|
|
|
|
value[label].append(tmp)
|
|
|
|
|
|
|
|
# if label not in value:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# value[label] = [tmp]
|
|
|
|
|
|
|
|
# else:
|
|
|
|
|
|
|
|
# value[label].append(tmp)
|
|
|
|
|
|
|
|
|
|
|
|
tmp['_index'] = len(value[label]) -1
|
|
|
|
tmp['_index'] = len(value[label]) -1
|
|
|
|
elif 'field' in _info :
|
|
|
|
elif 'field' in _info :
|
|
|
@ -490,7 +495,8 @@ class Parser (Process):
|
|
|
|
|
|
|
|
|
|
|
|
if _claim :
|
|
|
|
if _claim :
|
|
|
|
_claim['index'] = index #len(claims)
|
|
|
|
_claim['index'] = index #len(claims)
|
|
|
|
claims.append(dict(DEFAULT_VALUE,**_claim))
|
|
|
|
# claims.append(dict(DEFAULT_VALUE,**_claim))
|
|
|
|
|
|
|
|
claims.append( jsonmerge.merge(DEFAULT_VALUE,_claim))
|
|
|
|
segment = [row]
|
|
|
|
segment = [row]
|
|
|
|
index += 1
|
|
|
|
index += 1
|
|
|
|
|
|
|
|
|
|
|
@ -503,13 +509,19 @@ class Parser (Process):
|
|
|
|
|
|
|
|
|
|
|
|
claim = self.apply(segment,_code)
|
|
|
|
claim = self.apply(segment,_code)
|
|
|
|
if claim :
|
|
|
|
if claim :
|
|
|
|
|
|
|
|
|
|
|
|
claim['index'] = len(claims)
|
|
|
|
claim['index'] = len(claims)
|
|
|
|
# for _row_ in _toprows :
|
|
|
|
schema = [key for key in claim.keys() if type(claim[key]) == list]
|
|
|
|
|
|
|
|
if schema :
|
|
|
|
|
|
|
|
schema = {"properties":dict.fromkeys(schema,{"mergeStrategy":"append"})}
|
|
|
|
|
|
|
|
print (schema)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
schema = {}
|
|
|
|
|
|
|
|
merger = jsonmerge.Merger(schema)
|
|
|
|
|
|
|
|
top_row_claim = self.apply(_toprows,_code)
|
|
|
|
|
|
|
|
|
|
|
|
# claim = jsonmerge.merge(claim,self.apply([_row_],_code))
|
|
|
|
claim = merger.merge(claim,self.apply(_toprows,_code))
|
|
|
|
claim = jsonmerge.merge(claim,self.apply(_toprows,_code))
|
|
|
|
# claims.append(dict(DEFAULT_VALUE,**claim))
|
|
|
|
claims.append(dict(DEFAULT_VALUE,**claim))
|
|
|
|
claims.append(merger.merge(DEFAULT_VALUE,claim))
|
|
|
|
if type(file) != list :
|
|
|
|
if type(file) != list :
|
|
|
|
file.close()
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
|
|
|
|