Script 1609: Map SFDC Inputs
Purpose
The Python script maps Salesforce (SFDC) input data to a structured format for further analysis and reporting.
To Elaborate
The script is designed to process and map input data from Salesforce (SFDC) into a structured format that can be used for further analysis and reporting. It utilizes two primary data sources: one for input data and another for reference data. The script initializes various output columns with placeholder values, which are intended to be replaced with actual data during processing. The primary goal is to align and prepare the data for subsequent operations, such as calculating budget usage, tracking campaign performance, and managing account information. This structured approach ensures that the data is organized and ready for detailed analysis, enabling users to make informed decisions based on the insights derived from the processed data.
Walking Through the Code
- Initialization of Data Sources:
- The script begins by defining two primary data sources:
inputDf
andreportDf
. These data sources are extracted from a dictionary nameddataSourceDict
, with keys “1” and “2” respectively. inputDf
is the main data source containing Salesforce input data, whilereportDf
serves as a reference data source for additional information.
- The script begins by defining two primary data sources:
- Definition of Column Constants:
- The script defines several constants representing column names for both the primary and reference data sources. These constants are used to access specific columns within the data frames.
- Output DataFrame Initialization:
- A series of output columns are defined, each initialized with placeholder values (
"<<YOUR VALUE>>"
). These columns are intended to store processed data such as budget usage, campaign status, and account details. - The placeholders indicate that these values need to be populated with actual data during the processing phase.
- A series of output columns are defined, each initialized with placeholder values (
- Data Display:
- The script concludes by printing the first few rows of the
inputDf
data frame using thetableize
function, providing a preview of the input data for verification purposes.
- The script concludes by printing the first few rows of the
Vitals
- Script ID : 1609
- Client ID / Customer ID: 1306928593 / 60270593
- Action Type: Bulk Upload (Preview)
- Item Changed: Campaign
- Output Columns: Account, Campaign, Account Name, GUID, GUID Start Date, End Dates, Last Performance Added, Impressions to LPA, Impression Gap to LPA, Target Impressions to LPA, Total Contract Target Impressions, % On Pace, % of Budget Used, Remarketing Spend Budget for Niche, Spend to Date, Owner: Full Name, Type, Account Type, GUID Status
- Linked Datasource: M1 Report
- Reference Datasource: M1 Report
- Owner: emerryfield@marinsoftware.com (emerryfield@marinsoftware.com)
- Created by emerryfield@marinsoftware.com on 2025-01-07 03:19
- Last Updated by emerryfield@marinsoftware.com on 2025-01-07 03:19
> See it in Action
Python Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
##
## name: Map SFDC Inputs
## description:
##
##
## author:
## created: 2025-01-06
##
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN_ID = 'Campaign ID'
RPT_COL_SFDC_ID = 'SFDC ID'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_PUB_COST = 'Pub. Cost $'
# reference data source and columns
reportDf = dataSourceDict["2"] # report dataframe
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_CAMPAIGN_ID = 'Campaign ID'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_STRATEGY = 'Strategy'
RPT_COL_IMPR = 'Impr.'
# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_OF_BUDGET_USED = '% of Budget Used'
BULK_COL_ON_PACE = '% On Pace'
BULK_COL_ACCOUNT_NAME = 'Account Name'
BULK_COL_ACCOUNT_TYPE = 'Account Type'
BULK_COL_END_DATES = 'End Dates'
BULK_COL_GUID = 'GUID'
BULK_COL_GUID_START_DATE = 'GUID Start Date'
BULK_COL_GUID_STATUS = 'GUID Status'
BULK_COL_IMPRESSION_GAP_TO_LPA = 'Impression Gap to LPA'
BULK_COL_IMPRESSIONS_TO_LPA = 'Impressions to LPA'
BULK_COL_LAST_PERFORMANCE_ADDED = 'Last Performance Added'
BULK_COL_OWNER_FULL_NAME = 'Owner: Full Name'
BULK_COL_REMARKETING_SPEND_BUDGET_FOR_NICHE = 'Remarketing Spend Budget for Niche'
BULK_COL_SPEND_TO_DATE = 'Spend to Date'
BULK_COL_TARGET_IMPRESSIONS_TO_LPA = 'Target Impressions to LPA'
BULK_COL_TOTAL_CONTRACT_TARGET_IMPRESSIONS = 'Total Contract Target Impressions'
BULK_COL_TYPE = 'Type'
outputDf[BULK_COL_OF_BUDGET_USED] = "<<YOUR VALUE>>"
outputDf[BULK_COL_ON_PACE] = "<<YOUR VALUE>>"
outputDf[BULK_COL_ACCOUNT_NAME] = "<<YOUR VALUE>>"
outputDf[BULK_COL_ACCOUNT_TYPE] = "<<YOUR VALUE>>"
outputDf[BULK_COL_END_DATES] = "<<YOUR VALUE>>"
outputDf[BULK_COL_GUID] = "<<YOUR VALUE>>"
outputDf[BULK_COL_GUID_START_DATE] = "<<YOUR VALUE>>"
outputDf[BULK_COL_GUID_STATUS] = "<<YOUR VALUE>>"
outputDf[BULK_COL_IMPRESSION_GAP_TO_LPA] = "<<YOUR VALUE>>"
outputDf[BULK_COL_IMPRESSIONS_TO_LPA] = "<<YOUR VALUE>>"
outputDf[BULK_COL_LAST_PERFORMANCE_ADDED] = "<<YOUR VALUE>>"
outputDf[BULK_COL_OWNER_FULL_NAME] = "<<YOUR VALUE>>"
outputDf[BULK_COL_REMARKETING_SPEND_BUDGET_FOR_NICHE] = "<<YOUR VALUE>>"
outputDf[BULK_COL_SPEND_TO_DATE] = "<<YOUR VALUE>>"
outputDf[BULK_COL_TARGET_IMPRESSIONS_TO_LPA] = "<<YOUR VALUE>>"
outputDf[BULK_COL_TOTAL_CONTRACT_TARGET_IMPRESSIONS] = "<<YOUR VALUE>>"
outputDf[BULK_COL_TYPE] = "<<YOUR VALUE>>"
# user code start here
print(tableize(inputDf.head()))
Post generated on 2025-02-21 10:25:25 GMT