Ejemplo n.º 1
0
                              entity='contacts',
                              fields=fieldset,
                              filters=myFilter,
                              defName=exportDefName,
                              syncActions=[syncAction])

    logging.info("export definition created: " + exportDef['uri'])

    ## Create sync
    exportSync = elq.CreateSync(defObject=exportDef)
    logging.info("export sync started: " + exportSync['uri'])
    status = elq.CheckSyncStatus(syncObject=exportSync)
    logging.info("sync successful; retreiving data")

    ## Retrieve data
    data = elq.GetSyncedData(defObject=exportDef, retrieveLimit=80000)
    logging.info("# of records:" + str(len(data)))

    ## Setup logging vars
    total = len(data)

    if len(data) > 0:

        logging.info("Add to 'dwmQueue'")

        client = MongoClient(os.environ['MONGODB_URL'])

        db = client['dwmqueue']

        exportQueue = Queue(db=db, queueName='dwmQueue')
cdoDef = elq.CreateDef(defType='exports',
                       entity='customObjects',
                       cdoID=1269,
                       fields=myFields,
                       filters=myFilter,
                       defName=exportDefName)
logging.info("export definition created: " + cdoDef['uri'])

cdoSync = elq.CreateSync(defObject=cdoDef)
logging.info("export sync started: " + cdoSync['uri'])

status = elq.CheckSyncStatus(syncObject=cdoSync)
logging.info("sync successful; retreiving data")

data = elq.GetSyncedData(defObject=cdoDef)
logging.info("# of records:" + str(len(data)))

if (len(data) > 0):

    dataOut = data

    nullCount = 0

    sfdcCampaigns = sf.query_all(
        "SELECT Id, Solution_Code_Family__c, Solution_Code__c FROM Campaign")
    sfdcCampaignsId = dict((d['Id'], d) for d in sfdcCampaigns['records'])

    logging.info("Retreived SFDC Campaigns")

    for record in dataOut:
Ejemplo n.º 3
0
print(myFilter)

print("Tell the API what we want to export")
myExport = elq.CreateDef(entity='contacts',
                         defType='exports',
                         fields=myFields,
                         filters=myFilter,
                         defName="My zipcode export")
print("Start syncing the data for export")
mySync = elq.CreateSync(defObject=myExport)
status = elq.CheckSyncStatus(syncObject=mySync)
print(status)

print("Get the data...")

data = elq.GetSyncedData(defObject=myExport)
print(
    "Data has " + str(len(data)) + " records"
)  ## tells you how many records were exported; should match the number from our segment
print("First row: ")
print(data[0])  ## show us the first row of data

print("Clean up the zipcode values")
for row in data:
    if (row['Zip or Postal Code'] !=
            ''):  ## Only process if the zipcode field is not blank
        zip_old = row['Zip or Postal Code']  # get the value from the field
        zip_clean = re.split(
            '[^0-9]', zip_old
        )[0]  # if there are any spaces, dashes or breaks, get only the first string of numbers i.e.; '12345-123' becomes '12345', and '87890 NEW ADDRESS' becomes '87890'
        zip_clean = zip_clean[:5]  # trim down to only the first five digits