Script 1491: Offline Account Data

Purpose

The Python script processes and exports account data from a primary data source without modifications.

To Elaborate

The script is designed to handle account data by taking input from a specified data source and exporting it without making any changes. It ensures that the column headers in the output match those of the input data. The script allows for custom output columns by skipping output validations, which means it can be adapted to different output requirements without enforcing strict checks. This flexibility is useful in scenarios where the data structure might vary or when specific columns need to be included or excluded based on user requirements.

Walking Through the Code

  1. Data Source Initialization
    • The script begins by defining the primary data source, inputDf, which is retrieved from a dictionary dataSourceDict using the key "2_1". This data frame serves as the input for further processing.
  2. Data Export
    • The script creates a copy of the input data frame, outputDf, ensuring that the data remains unchanged. It explicitly sets the column headers of outputDf to match those of inputDf, maintaining consistency in the data structure.
  3. Custom Output Handling
    • A flag, skip_output_validations, is set to True, allowing the script to bypass any output validation checks. This feature provides flexibility for users to define custom output columns without being restricted by predefined validation rules.
  4. Data Display
    • The script concludes by printing a tabular representation of the first few rows of outputDf using the tableize function, offering a quick view of the data being processed.

Vitals

  • Script ID : 1491
  • Client ID / Customer ID: 1306927965 / 60270405
  • Action Type: Revenue Upload (Preview)
  • Item Changed: None
  • Output Columns: Date, Keyword ID, Creative ID, Keyword, Match Type, Group ID, Campaign ID, Property Published (Conv Date) Conv, Property Registered (Conv Date) Conv, Property Validated (Conv Date) Conv
  • Linked Datasource: FTP/Email Feed
  • Reference Datasource: Google Sheets
  • Owner: Tom McCaughey (tmccaughey@marinsoftware.com)
  • Created by Tom McCaughey on 2024-11-07 11:10
  • Last Updated by Tom McCaughey on 2024-11-07 11:26
> 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
##
## name: Offline Account Data
## description:
##  
## 
## author: 
## created: 2024-11-07
## 

import datetime

today = datetime.datetime.now(CLIENT_TIMEZONE).date()

# primary data source and columns
inputDf = dataSourceDict["2_1"]

# Export inputDf without any changes
outputDf = inputDf.copy()
outputDf.columns = inputDf.columns  # Set column headers to match those of inputDf

#allow for custom output columns
skip_output_validations = True

# user code start here
print(tableize(outputDf.head()))

Post generated on 2024-11-27 06:58:46 GMT

comments powered by Disqus