Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Fixed unit of measure bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kjod committed Jun 2, 2017
1 parent a6e6454 commit 3edc7e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions ZOOM/lib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def identify_col_dtype(column_values, file_heading, dicts, sample=None): #only t
error_counter.append((dicts[temp_value],counter))
dtypes_found.append(dicts[temp_value])
except Exception:
print("Unicode error")
print("Unicode error, checking if another datatype")

"""if value in iso2_codes_dict:#try:#change to if statements, expections more costly than ifs
check_dtype = "iso2"
Expand Down Expand Up @@ -354,6 +354,7 @@ def convert_df(mappings,relationship_dict, left_over_dict, df_data, dtypes_dict,
new_df = pd.DataFrame( columns = columns)

counter = 0
new_df['unit_of_measure'] = 0

for i in range(len(df_data[columns_set[0]])):#columns[0] bad idea, fix
#for col in columns_set:
Expand Down Expand Up @@ -386,8 +387,10 @@ def convert_df(mappings,relationship_dict, left_over_dict, df_data, dtypes_dict,
new_df[left_over_dict[col]][counter] = df_data[col.replace("~", " ")][i]

if col.replace("~", " ") in empty_unit_measure_value:
new_df['unit_of_measure'] = empty_unit_measure_value[col.replace("~", " ")]

#print("getting unit of measure")
#print(col.replace("~", " "))
#print(empty_unit_measure_value[col.replace("~", " ")])
new_df['unit_of_measure'][counter] = empty_unit_measure_value[col.replace("~", " ")]
#new_df = df_data[mappings[key]]
#map value

Expand Down
3 changes: 2 additions & 1 deletion ZOOM/manual_mapping/manual_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ def manual_mapper(data):

if unit_of_measure_value:
if len(unit_of_measure_value.keys()) < 2 :#chect each entry emoty unit_of measure a dict
#print(unit_of_measure_value)
mappings['unit_of_measure'] = ['unit_of_measure']
df_data['unit_of_measure'] = unit_of_measure_value[unit_of_measure_value.keys()[0]]
dtypes_dict[mappings['unit_of_measure'][0]] = [('str', 'str')]
else:
#print("Unit of measure values")
#print(unit_of_measure_value)
mappings['unit_of_measure'] = ['unit_of_measure']
dtypes_dict[mappings['unit_of_measure'][0]] = [('str', 'str')]

Expand Down

0 comments on commit 3edc7e8

Please sign in to comment.