Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add is_omitted column to column mapping profiles #46

Merged
merged 3 commits into from
Sep 23, 2024
Merged
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
8 changes: 5 additions & 3 deletions pyseed/seed_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ def create_or_update_column_mapping_profile(
"from_units": null,
"to_table_name": "PropertyState"
"to_field": "address_line_1",
"is_omitted": False
},
{
"from_field": "address1",
Expand All @@ -934,6 +935,7 @@ def create_or_update_column_mapping_profile(
...
]

The is_omitted mapping may be absent - it is treated as False if it is not present.
Returns:
dict: {
'id': 1
Expand Down Expand Up @@ -972,9 +974,9 @@ def create_or_update_column_mapping_profile_from_file(
) -> dict:
"""creates or updates a mapping profile. The format of the mapping file is a CSV with the following format:

Raw Columns, units, SEED Table, SEED Columns\n
PM Property ID, , PropertyState, pm_property_id\n
Building ID, , PropertyState, custom_id_1\n
Raw Columns, units, SEED Table, SEED Columns, Omit\n
PM Property ID, , PropertyState, pm_property_id, False\n
Building ID, , PropertyState, custom_id_1, False\n
...\n

This only works for 'Normal' column mapping profiles, that is, it does not work for
Expand Down
21 changes: 12 additions & 9 deletions pyseed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,18 @@ def read_map_file(mapfile_path):

# Open the mapping file and fill list
maplist = list()

for rowitem in map_reader:
maplist.append(
{
'from_field': rowitem[0],
'from_units': rowitem[1],
'to_table_name': rowitem[2],
'to_field': rowitem[3],
}
)
data = {
"from_field": rowitem[0],
"from_units": rowitem[1],
"to_table_name": rowitem[2],
"to_field": rowitem[3],
}
try:
data["is_omitted"] = True if rowitem[4].lower().strip() == "true" else False
except IndexError:
data["is_omitted"] = False

maplist.append(data)

return maplist
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ def test_mapping_file(self):
"from_units": "ft**2",
"to_field": "gross_floor_area",
"to_table_name": "PropertyState",
"is_omitted": False
}
assert mappings[5] == expected