headers.append('Geoprecision')
		headers.append('Address Type')
		headers.append('Delivery Point')
		headers.append('Receiving Mail')
		headers.append('Landline Phone')
		csvWriter.writerow(row[:-2]+headers)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results','','','',''])
			continue
		
		error = wppbatchlib.nvl(data.get('error',{}),{}).get('message','')
		results = wppbatchlib.nvl(data.get('results',[{}]),[{}])
					
							
		if error == '' and len(results[0].keys()) == 0:
			error = 'No results found'
		
		resultNum = 0
		totalResults = len(results)
		for primaryPerson in results:
			primaryPersonKey = primaryPerson.get('id',{}).get('key')
			resultNum += 1
			
			locs = primaryPerson.get('locations',[{}])
			
			for location in locs:
for row in csvReader:
	#each raw results row will contain the original input file row, followed by the API URL,
	#followed by the JSON response.
	rowNum += 1
	if rowNum == 1:
		csvWriter.writerow(row[:-2]+['Error','Reputation Level','Reputation Details','Report Count','Volume Score'])
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results','','','',''])
			continue
		
		error = wppbatchlib.nvl(data.get('error',{}),{}).get('message','')
		results = wppbatchlib.nvl(data.get('results',[{}]),[{}])[0]
		rep = wppbatchlib.nvl(results.get('reputation',{}),{})
		repLevel = rep.get('level','')
		repVolume = rep.get('volume_score','')
		repReport = rep.get('report_count','')
		repDetails = ''
		numDetails = 0
		for x in rep.get('details',[]):
			numDetails += 1
			if numDetails > 1:
				repDetails += '|'
			repDetails += x.get('type','')
			repDetails += ';'
			repDetails += x.get('category','')
			repDetails += ';'
        headers.append("Location LatLon Accuracy")
        headers.append("Location Latitude")
        headers.append("Location Longitude")
        csvWriter.writerow(row[:-2] + headers)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print "Error reading JSON on row " + str(rowNum)
            csvWriter.writerow(row[:-2] + ["Failed to load JSON results", "", "", "", ""])
            continue

        resultNum = 0

        error = wppbatchlib.nvl(data.get("error", {}), {}).get("message", "")
        inputPhone = data.get("phone_number", "")
        lineType = data.get("line_type", "")
        carrier = data.get("carrier", "")
        isValid = data.get("is_valid", "")
        isPrepaid = data.get("is_prepaid", "")
        isCommercial = data.get("is_commercial", "")

        belongsTo = wppbatchlib.nvl(data.get("belongs_to", [{}]), [{}])
        currAddresses = wppbatchlib.nvl(data.get("current_addresses", [{}]), [{}])
        associatedPeople = wppbatchlib.nvl(data.get("associated_people", []), [])

        for owner in [belongsTo[0]]:

            name = wppbatchlib.nvl(owner.get("name", ""), "")
            ageRange = wppbatchlib.nvl(owner.get("age_range", ""), "")
	#followed by the JSON response.
	
	rowNum += 1
	if rowNum == 1:
		csvWriter.writerow(row[:-2]+headerRow)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results'])
			continue
		resultRow = []
		resultRow.append('')
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.is_valid',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.warnings',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.phone_to_name',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.phone_to_address',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.subscriber_name',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.country_code',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.line_type',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.carrier',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.is_prepaid',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.is_connected',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.phone.is_commercial',''),''))
		
		resultRow.append(wppbatchlib.nvl(data.get('primary.address.is_valid',''),''))
		resultRow.append(wppbatchlib.nvl(data.get('primary.address.warnings',['']),[''])[0])
		resultRow.append(wppbatchlib.nvl(data.get('primary.address.diagnostics',['']),[''])[0])
		resultRow.append(wppbatchlib.nvl(data.get('primary.address.address_to_name',''),''))
        csvWriter.writerow(row[:-2] + [
            'Error', 'ID', 'is_valid', 'street_line_1', 'street_line_2',
            'city', 'state_code', 'postal_code', 'zip4', 'country_code',
            'latitude', 'longitude', 'latlon precision', 'diagnostics'
        ])
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] +
                               ['Failed to load JSON results', '', '', '', ''])
            continue

        error = wppbatchlib.nvl(data.get('error', {}), {}).get('message', '')
        id = data.get('id', '')
        isvalid = data.get('is_valid', '')
        line1 = data.get('street_line_1', '')
        line2 = data.get('street_line_2', '')
        city = data.get('city', '')
        state = data.get('state_code', '')
        zip = data.get('postal_code', '')
        zip4 = data.get('zip4', '')
        country = data.get('country_code', '')
        lat = wppbatchlib.nvl(data.get('lat_long', {}), {}).get('latitude', '')
        lon = wppbatchlib.nvl(data.get('lat_long', {}),
                              {}).get('longitude', '')
        latlonacc = wppbatchlib.nvl(data.get('lat_long', {}),
                                    {}).get('accuracy', '')
        diagnostic = wppbatchlib.nvl(data.get('diagnostics', ['']), [''])[0]
Example #6
0
        headers.append('Reputation Level')
        headers.append('Reputation Details')
        headers.append('Report Count')
        headers.append('Volume Score')
        csvWriter.writerow(row[:-2] + headers)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] +
                               ['Failed to load JSON results', '', '', '', ''])
            continue

        error = wppbatchlib.nvl(data.get('error', {}), {}).get('message', '')
        results = wppbatchlib.nvl(data.get('results', [{}]), [{}])[0]
        lineType = results.get('line_type', '')
        carrier = results.get('carrier', '')
        isValid = results.get('is_valid', '')
        isConnected = results.get('is_connected', '')
        isPrepaid = results.get('is_prepaid', '')
        dncRegistered = results.get('do_not_call', '')
        rep = wppbatchlib.nvl(results.get('reputation', {}), {})
        repLevel = rep.get('level', '')
        repVolume = rep.get('volume_score', '')
        repReport = rep.get('report_count', '')
        repDetails = ''
        numDetails = 0
        for x in rep.get('details', []):
            numDetails += 1
		headers.append('Location Receiving Mail')
		headers.append('Location LatLon Accuracy')
		headers.append('Location Latitude')
		headers.append('Location Longitude')
		headers.append('Landline Phone')
		csvWriter.writerow(row[:-2]+headers)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results','','','',''])
			continue
		
		error = wppbatchlib.nvl(data.get('error',{}),{}).get('message','')
		results = wppbatchlib.nvl(data.get('results',[{}]),[{}])
					
		if error == '':
			if results == None or len(results[0].keys()) == 0:
				error = 'No results found'
		
		resultNum = 0
		for location in results:
					
			isHistorical = location.get('is_historical','')	
			locType = location.get('type','')
			
			street = location.get('standard_address_line1','')
			city = location.get('city','')
			state = location.get('state_code','')
        isHistorical = data.get('is_historical', '')

        street = data.get('street_line_1', '')
        city = data.get('city', '')
        state = data.get('state_code', '')
        postalCode = data.get('postal_code', '')
        zip4 = data.get('zip4', '')
        country = data.get('country_code', '')
        deliveryPoint = data.get('delivery_point', '')
        isCommercial = data.get('is_commercial', '')
        rcvMail = data.get('is_active', '')
        isForwarder = data.get('is_forwarder', '')
        lastSaleDate = data.get('last_sale_date', '')
        totalValue = '$' + str(data.get('total_value', ''))

        latLonAccuracy = wppbatchlib.nvl(data.get('lat_long', {}),
                                         {}).get('accuracy', '')
        latitude = wppbatchlib.nvl(data.get('lat_long', {}),
                                   {}).get('latitude', '')
        longitude = wppbatchlib.nvl(data.get('lat_long', {}),
                                    {}).get('longitude', '')
        owner = ""
        #fetch owners
        for owners in wppbatchlib.nvl(data.get('owners', [{}]), [{}]):

            owner += str(owners.get('name')) + '; '
            decodedRow = []

        #fetch occupants
        for occupant in wppbatchlib.nvl(data.get('current_residents', [{}]),
                                        [{}]):
Example #9
0
        headers.append('Location LatLon Accuracy')
        headers.append('Location Latitude')
        headers.append('Location Longitude')
        headers.append('Landline Phone')
        csvWriter.writerow(row[:-2] + headers)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] +
                               ['Failed to load JSON results', '', '', '', ''])
            continue

        error = wppbatchlib.nvl(data.get('error', {}), {}).get('message', '')
        results = wppbatchlib.nvl(data.get('results', [{}]), [{}])

        if error == '' and len(results[0].keys()) == 0:
            error = 'No results found'

        resultNum = 0
        actualResultNum = 0
        for primaryPerson in results:
            primaryPersonKey = primaryPerson.get('id', {}).get('key')
            resultNum += 1

            locs = primaryPerson.get('locations', [{}])

            for location in locs:
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results'])
			continue
		
		resultRow = []
		
		
		errors = []
		
		
		if wppbatchlib.nvl(data.get('name_checks',{}),{}).get('error',None) is not None:
			errors.append('Name: '+wppbatchlib.nvl(data.get('name_checks',{}),{}).get('error',{}).get('message',''))
		if wppbatchlib.nvl(data.get('phone_checks',{}),{}).get('error',None) is not None:
			errors.append('Phone: '+wppbatchlib.nvl(data.get('phone_checks',{}),{}).get('error',{}).get('message',''))
		if wppbatchlib.nvl(data.get('address_checks',{}),{}).get('error',None) is not None:
			errors.append('Address: '+wppbatchlib.nvl(data.get('address_checks',{}),{}).get('error',{}).get('message',''))
		if wppbatchlib.nvl(data.get('email_address_checks',{}),{}).get('error',None) is not None:
			errors.append('Email: '+wppbatchlib.nvl(data.get('email_address_checks',{}),{}).get('error',{}).get('message',''))
		if wppbatchlib.nvl(data.get('ip_address_checks',{}),{}).get('error',None) is not None:
			errors.append('IP Address: '+wppbatchlib.nvl(data.get('ip_address_checks',{}),{}).get('error',{}).get('message',''))
		
		resultRow.append('; '.join(errors))
		
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('phone_checks',{}),{}).get('phone_contact_score',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('phone_checks',{}),{}).get('is_valid',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('phone_checks',{}),{}).get('warnings',''),''))
Example #11
0
    rowNum += 1
    if rowNum == 1:
        csvWriter.writerow(row[:-2] + headerRow)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] + ['Failed to load JSON results'])
            continue
        resultRow = []
        resultRow.append('')
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.is_valid', ''), ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.warnings', ''), ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.phone_to_name', ''), ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.phone_to_address', ''),
                            ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.subscriber_name', ''), ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.country_code', ''), ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.line_type', ''), ''))
        resultRow.append(
            wppbatchlib.nvl(data.get('primary.phone.carrier', ''), ''))
Example #12
0
 rowNum += 1
 if rowNum == 1:
     csvWriter.writerow(row[:-2] + headerRow)
 else:
     data = {}
     try:
         data = json.loads(row[-1])
     except:
         print 'Error reading JSON on row ' + str(rowNum)
         csvWriter.writerow(row[:-2] + ['Failed to load JSON results'])
         continue
     resultRow = []
     resultRow.append('')
     resultRow.append(
         wppbatchlib.nvl(
             wppbatchlib.nvl(data.get('primary_phone_checks', {}),
                             {}).get('is_valid', ''), ''))
     resultRow.append(
         wppbatchlib.nvl(
             wppbatchlib.nvl(data.get('primary_phone_checks', {}),
                             {}).get('warnings', ''), ''))
     resultRow.append(
         wppbatchlib.nvl(
             wppbatchlib.nvl(data.get('primary_phone_checks', {}),
                             {}).get('phone_to_name', ''), ''))
     resultRow.append(
         wppbatchlib.nvl(
             wppbatchlib.nvl(data.get('primary_phone_checks', {}),
                             {}).get('phone_to_address', ''), ''))
     resultRow.append(
         wppbatchlib.nvl(
		headers.append('Location Receiving Mail')
		headers.append('Location LatLon Accuracy')
		headers.append('Location Latitude')
		headers.append('Location Longitude')
		headers.append('Landline Phone')
		csvWriter.writerow(row[:-2]+headers)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results','','','',''])
			continue
		
		error = wppbatchlib.nvl(data.get('error',{}),{}).get('message','')
		results = wppbatchlib.nvl(data.get('results',[{}]),[{}])
					
		if len(results[0].keys()) == 0:
			error = 'No results found'
		
		resultNum = 0
		for result in results:
			resultNum += 1
			
			bizName = result.get('name','')
			
			phoneNumber = ''
			phones = wppbatchlib.nvl(result.get('phones',[{}]),[{}])
			if phones is not None:
				for p in phones:
	#followed by the JSON response.
	
	rowNum += 1
	if rowNum == 1:
		csvWriter.writerow(row[:-2]+headerRow)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results'])
			continue
		resultRow = []
		resultRow.append('')
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('is_valid',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('warnings',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('phone_to_name',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('phone_to_address',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('subscriber_name',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('country_code',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('line_type',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('carrier',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('is_prepaid',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('is_connected',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_phone_checks',{}),{}).get('is_commercial',''),''))
		
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_address_checks',{}),{}).get('is_valid',''),''))
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_address_checks',{}),{}).get('warnings',['']),[''])[0])
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_address_checks',{}),{}).get('diagnostics',['']),[''])[0])
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('primary_address_checks',{}),{}).get('address_to_name',''),''))
Example #15
0
		headers.append('Location Receiving Mail')
		headers.append('Location LatLon Accuracy')
		headers.append('Location Latitude')
		headers.append('Location Longitude')
		headers.append('Landline Phone')
		csvWriter.writerow(row[:-2]+headers)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results','','','',''])
			continue
		
		error = wppbatchlib.nvl(data.get('error',{}),{}).get('message','')
		results = wppbatchlib.nvl(data.get('person',[{}]),[{}])
					
							
		if error == '' and len(results[0].keys()) == 0:
			error = 'No results found'
		
		resultNum = 0
		for primaryPerson in results:
			primaryPersonKey = primaryPerson.get('person',{}).get('id')
			resultNum += 1
			
			
			locs = primaryPerson.get('current_addresses',[{}])
			bestIndex = 0
			
        headers.append('Line Type')
        headers.append('Carrier')
        headers.append('Is Valid')
        headers.append('isPrepaid')
        csvWriter.writerow(row[:-2] + headers)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] +
                               ['Failed to load JSON results', '', '', '', ''])
            continue

        error = wppbatchlib.nvl(data.get('error', {}), {}).get('message', '')
        lineType = data.get('line_type', '')
        carrier = data.get('carrier', '')
        isValid = data.get('is_valid', '')
        isPrepaid = data.get('is_prepaid', '')

        resultRow = [error]
        resultRow.append(lineType)
        resultRow.append(carrier)
        resultRow.append(isValid)
        resultRow.append(isPrepaid)
        decodedRow = []
        for a in resultRow:
            if a is None:
                a = ''
            try:
Example #17
0
        headers.append('Location LatLon Accuracy')
        headers.append('Location Latitude')
        headers.append('Location Longitude')
        headers.append('Landline Phone')
        csvWriter.writerow(row[:-2] + headers)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] +
                               ['Failed to load JSON results', '', '', '', ''])
            continue

        error = wppbatchlib.nvl(data.get('error', {}), {}).get('message', '')
        results = wppbatchlib.nvl(data.get('results', [{}]), [{}])

        if len(results[0].keys()) == 0:
            error = 'No results found'

        resultNum = 0
        for result in results:
            resultNum += 1

            bizName = result.get('name', '')

            phoneNumber = ''
            phones = wppbatchlib.nvl(result.get('phones', [{}]), [{}])
            if phones is not None:
                for p in phones:
Example #18
0
    rowNum += 1
    if rowNum == 1:
        csvWriter.writerow(row[:-2] + headerRow)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] + ['Failed to load JSON results'])
            continue
        resultRow = []
        resultRow.append('')
        resultRow.append(
            wppbatchlib.nvl(
                wppbatchlib.nvl(data.get('stolen_identity_check', {}),
                                {}).get('risk_level', ''), ''))

        decodedRow = []
        for a in resultRow:
            if a is None:
                a = ''
            try:
                decodedRow.append(a.encode('utf-8'))
            except:
                try:
                    decodedRow.append(str(a))
                except:
                    decodedRow.append(a)

        try:
Example #19
0
		headers.append('Location LatLon Accuracy')
		headers.append('Location Latitude')
		headers.append('Location Longitude')
		csvWriter.writerow(row[:-2]+headers)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results','','','',''])
			continue
		
		resultNum = 0
		
		error = wppbatchlib.nvl(data.get('error',{}),{}).get('message','')
		inputPhone = data.get('phone_number','')
		lineType = data.get('line_type','')
		carrier = data.get('carrier','')
		isValid = data.get('is_valid','')
		isPrepaid = data.get('is_prepaid','')
		isCommercial = data.get('is_commercial','')
				
		belongsTo = wppbatchlib.nvl(data.get('belongs_to',[{}]),[{}])
		currAddresses = wppbatchlib.nvl(data.get('current_addresses',[{}]),[{}])
		associatedPeople = wppbatchlib.nvl(data.get('associated_people',[]),[])
		
		for owner in belongsTo:
	
			name = wppbatchlib.nvl(owner.get('name',''),'')
			ageRange = wppbatchlib.nvl(owner.get('age_range',''),'')
        csvWriter.writerow(row[:-2] + [
            'Error', 'Warning', 'Reputation Level', 'Volume Score',
            'Report Count', 'Reputation Score', 'Reputation Type',
            'Reputation Category'
        ])
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] +
                               ['Failed to load JSON results', '', '', '', ''])
            continue

        error = wppbatchlib.nvl(data.get('error', {}), {}).get('message', '')
        warning = data.get('warnings', '')
        repLevel = data.get('reputation_level', '')
        repVolume = data.get('volume_score', '')
        repReport = data.get('report_count', '')
        score = wppbatchlib.nvl(data.get('reputation_details', {}),
                                {}).get('score', '')
        type = wppbatchlib.nvl(data.get('reputation_details', {}),
                               {}).get('type', '')
        category = wppbatchlib.nvl(data.get('reputation_details', {}),
                                   {}).get('category', '')

        resultRow = [
            error, warning, repLevel, repVolume, repReport, score, type,
            category
        ]
	#followed by the JSON response.
	
	rowNum += 1
	if rowNum == 1:
		csvWriter.writerow(row[:-2]+headerRow)
	else:
		data = {}
		try:
			data = json.loads(row[-1])
		except:
			print 'Error reading JSON on row '+str(rowNum)
			csvWriter.writerow(row[:-2]+['Failed to load JSON results'])
			continue
		resultRow = []
		resultRow.append('')
		resultRow.append(wppbatchlib.nvl(wppbatchlib.nvl(data.get('stolen_identity_check',{}),{}).get('risk_level',''),''))
		
		decodedRow = []
		for a in resultRow:
			if a is None:
				a = ''
			try:
				decodedRow.append(a.encode('utf-8'))
			except:
				try:
					decodedRow.append(str(a))
				except:
					decodedRow.append(a)
			
		try:
			csvWriter.writerow(row[:-2]+decodedRow)
Example #22
0
    if rowNum == 1:
        csvWriter.writerow(row[:-2] + headerRow)
    else:
        data = {}
        try:
            data = json.loads(row[-1])
        except:
            print 'Error reading JSON on row ' + str(rowNum)
            csvWriter.writerow(row[:-2] + ['Failed to load JSON results'])
            continue

        resultRow = []

        errors = []

        if wppbatchlib.nvl(data.get('name_checks', {}),
                           {}).get('error', None) is not None:
            errors.append('Name: ' +
                          wppbatchlib.nvl(data.get('name_checks', {}), {}).get(
                              'error', {}).get('message', ''))
        if wppbatchlib.nvl(data.get('phone_checks', {}),
                           {}).get('error', None) is not None:
            errors.append('Phone: ' +
                          wppbatchlib.nvl(data.get('phone_checks', {}), {}).
                          get('error', {}).get('message', ''))
        if wppbatchlib.nvl(data.get('address_checks', {}),
                           {}).get('error', None) is not None:
            errors.append('Address: ' +
                          wppbatchlib.nvl(data.get('address_checks', {}), {}).
                          get('error', {}).get('message', ''))
        if wppbatchlib.nvl(data.get('email_address_checks', {}),
                           {}).get('error', None) is not None: