|
|
|
@ -13,13 +13,8 @@ read_df_ibr = pd.read_csv('../1_extract_data/results/SCInstalledBaseRole__c.csv'
|
|
|
|
|
read_df_pricelist = pd.read_csv('../1_extract_data/results/SCPriceList__c.csv', header=0, keep_default_na=False, dtype=str)
|
|
|
|
|
read_df_pricelistitem = pd.read_csv('../1_extract_data/results/SCPriceListItem__c.csv', header=0, keep_default_na=False, dtype=str)
|
|
|
|
|
read_df_resourceassignment = pd.read_csv('../1_extract_data/results/SCResourceAssignment__c.csv', header=0, keep_default_na=False, dtype=str)
|
|
|
|
|
|
|
|
|
|
for row in read_df.to_dict('records'):
|
|
|
|
|
try:
|
|
|
|
|
# Your processing logic here
|
|
|
|
|
pass
|
|
|
|
|
except KeyError as e:
|
|
|
|
|
print(f'KeyError: {e}')
|
|
|
|
|
read_df_address_iot = pd.read_csv('../1_extract_data/results/Address.csv', header=0, keep_default_na=False, dtype=str)
|
|
|
|
|
read_df_location_iot = pd.read_csv('../1_extract_data/results/ParentLocation.csv', header=0, keep_default_na=False, dtype=str)
|
|
|
|
|
|
|
|
|
|
# Columns for reindexing
|
|
|
|
|
reindex_columns = ['Id','City__c','Country__c','GeoY__c','GeoX__c','PostalCode__c','Street__c','Extension__c','HouseNo__c','FlatNo__c','Floor__c']
|
|
|
|
@ -29,6 +24,8 @@ reindex_columns_ibr = ['Id', 'InstalledBaseLocation__c', 'Role__c', 'ValidFrom__
|
|
|
|
|
reindex_columns_pricelist = ['Id', 'Name', 'Brand__r.Name', 'Country__c']
|
|
|
|
|
reindex_columns_pricelistitem = ['Id', 'Article__r.Name', 'Article__r.EANCode__c', 'Price__c', 'PriceUnit__c', 'Pricelist__c', 'ValidFrom__c', 'ValidTo__c', 'Pricelist__r.Brand__r.Name', 'Pricelist__r.Country__c']
|
|
|
|
|
reindex_columns_resourceassignment = ['Id', 'ValidTo__c', 'ValidFrom__c', 'Country__c', 'City__c', 'District__c', 'Street__c', 'HouseNo__c', 'Extension__c', 'FlatNo__c', 'Floor__c', 'GeoY__c', 'GeoX__c', 'Resource__c', 'Stock__c']
|
|
|
|
|
reindex_columns_address_iot = ['Id', 'Country', 'CountryCode', 'Street', 'City', 'ParentId', 'PostalCode']
|
|
|
|
|
reindex_columns_location_iot = ['Id', 'Name']
|
|
|
|
|
|
|
|
|
|
# Reindex the columns to match the desired format
|
|
|
|
|
df = read_df.reindex(reindex_columns, axis=1)
|
|
|
|
@ -38,6 +35,29 @@ df_ibr = read_df_ibr.reindex(reindex_columns_ibr, axis=1)
|
|
|
|
|
df_pricelist = read_df_pricelist.reindex(reindex_columns_pricelist, axis=1)
|
|
|
|
|
df_pricelistitem = read_df_pricelistitem.reindex(reindex_columns_pricelistitem, axis=1)
|
|
|
|
|
df_resourceassignment = read_df_resourceassignment.reindex(reindex_columns_resourceassignment, axis=1)
|
|
|
|
|
df_address_iot = read_df_address_iot.reindex(reindex_columns_address_iot, axis=1)
|
|
|
|
|
df_location_iot = read_df_location_iot.reindex(reindex_columns_location_iot, axis=1)
|
|
|
|
|
|
|
|
|
|
##--------------------------------------------------------------------------##
|
|
|
|
|
## Update for IoT Addresses and Locations
|
|
|
|
|
##--------------------------------------------------------------------------##
|
|
|
|
|
|
|
|
|
|
df_address_iot['PKey__c'] = (
|
|
|
|
|
df_address_iot['Street'].astype(str) + ', ' +
|
|
|
|
|
df_address_iot['PostalCode'].astype(str) + ' ' +
|
|
|
|
|
df_address_iot['City'].astype(str) + ', ' +
|
|
|
|
|
df_address_iot['CountryCode'].astype(str)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
merged_df_location_iot = pd.merge(df_location_iot,
|
|
|
|
|
df_address_iot[['Id', 'ParentId', 'PKey__c']],
|
|
|
|
|
left_on='Id',
|
|
|
|
|
right_on='ParentId',
|
|
|
|
|
how='left')
|
|
|
|
|
|
|
|
|
|
merged_df_location_iot = merged_df_location_iot.drop('ParentId', axis=1)
|
|
|
|
|
|
|
|
|
|
merged_df_location_iot.columns = ['Id', 'Name', 'VisitorAddressId', 'PKey__c']
|
|
|
|
|
|
|
|
|
|
##--------------------------------------------------------------------------##
|
|
|
|
|
## Address and Location (Parent and Child)
|
|
|
|
@ -305,13 +325,14 @@ df_pricelistitem.columns = columns_pricebookentry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Write each DataFrame to a separate CSV file
|
|
|
|
|
address_df.to_csv('../3_upsert_address_and_parent_location/Address.csv', index=False)
|
|
|
|
|
parent_df.to_csv('../3_upsert_address_and_parent_location/Location.csv', index=False)
|
|
|
|
|
child_df.to_csv('../5_upsert_child_location/Location.csv', index=False)
|
|
|
|
|
merged_df_ib.to_csv('../7_upsert_assets/Asset.csv', index=False)
|
|
|
|
|
df_ibr.to_csv('../10_upsert_associated_location/AssociatedLocation.csv', index=False)
|
|
|
|
|
df_pricelist.to_csv('../11_insert_pricebook2_and_pricebookentries/Pricebook2.csv', index=False)
|
|
|
|
|
df_pricelistitem.to_csv('../11_insert_pricebook2_and_pricebookentries/PricebookEntry.csv', index=False)
|
|
|
|
|
address_df.to_csv('../4_upsert_address_and_parent_location/Address.csv', index=False)
|
|
|
|
|
parent_df.to_csv('../4_upsert_address_and_parent_location/Location.csv', index=False)
|
|
|
|
|
child_df.to_csv('../6_upsert_child_location/Location.csv', index=False)
|
|
|
|
|
merged_df_ib.to_csv('../8_upsert_assets/Asset.csv', index=False)
|
|
|
|
|
df_ibr.to_csv('../11_upsert_associated_location/AssociatedLocation.csv', index=False)
|
|
|
|
|
df_pricelist.to_csv('../12_insert_pricebook2_and_pricebookentries/Pricebook2.csv', index=False)
|
|
|
|
|
df_pricelistitem.to_csv('../12_insert_pricebook2_and_pricebookentries/PricebookEntry.csv', index=False)
|
|
|
|
|
merged_df_location_iot.to_csv('../3_update_address_and_location_data_for_migration/Location.csv', index=False)
|
|
|
|
|
|
|
|
|
|
## end mapping
|
|
|
|
|
|
|
|
|
|