(submit_json)
Transform periodic data into a format that is kissmetric submission friendly, then call identify
    csv format: Identity (email), timestamp (epoch), Prop:<Property name>, etc...
    :param submit_json: Example Json below, this function assumes
    [
      {
        email: <>,
        properties: [
          {
            property: <>,
            value: <>
          }, (can have more than one)
        ]
      }
    ]
    :return: none
Transform periodic data into a format that is kissmetric submission friendly, then call identify
    csv format: Identity (email), timestamp (epoch), Prop:<Property name>, etc...
    :param submit_json: Example Json below, this function assumes
    [
      {
        email: <>,
        properties: [
          {
            property: <>,
            value: <>
          }, (can have more than one)
        ]
      }
    ]
    :return: none
Transform periodic data into a format that is kissmetric submission friendly then call identify csv format : Identity ( email ) timestamp ( epoch ) Prop : <Property name > etc ... : param submit_json : Example Json below this function assumes [ { email : < > properties : [ { property : < > value : < > } ( can have more than one ) ] } ] : return : none
def _track_periodic_data_on_kiss(submit_json):
    """
    Transform periodic data into a format that is kissmetric submission friendly, then call identify
    csv format: Identity (email), timestamp (epoch), Prop:<Property name>, etc...
    :param submit_json: Example Json below, this function assumes
    [
      {
        email: <>,
        properties: [
          {
            property: <>,
            value: <>
          }, (can have more than one)
        ]
      }
    ]
    :return: none
    """
    periodic_data_list = json.loads(submit_json)

    headers = [
        'Identity',
        'Timestamp',
    ] + ['Prop:{}'.format(prop['property']) for prop in periodic_data_list[0]['properties']]

    filename = 'periodic_data.{}.csv'.format(date.today().strftime('%Y%m%d'))
    with open(filename, 'w') as csvfile:
        csvwriter = csv.writer(csvfile)
        csvwriter.writerow(headers)

        for webuser in periodic_data_list:
            row = [
                webuser['email'],
                int(time.time())
            ] + [prop['value'] for prop in webuser['properties']]
            csvwriter.writerow(row)

    if settings.S3_ACCESS_KEY and settings.S3_SECRET_KEY and settings.ANALYTICS_IDS.get('KISSMETRICS_KEY', None):
        s3_connection = tinys3.Connection(settings.S3_ACCESS_KEY, settings.S3_SECRET_KEY, tls=True)
        f = open(filename, 'rb')
        s3_connection.upload(filename, f, 'kiss-uploads')

    os.remove(filename)
def _track_periodic_data_on_kiss ( submit_json ) : periodic_data_list = json . loads ( submit_json ) headers = [ 'Identity' , 'Timestamp' , ] + [ 'Prop:{}' . format ( prop [ 'property' ] ) for prop in periodic_data_list [ 0 ] [ 'properties' ] ] filename = 'periodic_data.{}.csv' . format ( date . today ( ) . strftime ( '%Y%m%d' ) ) with open ( filename , 'w' ) as csvfile : csvwriter = csv . writer ( csvfile ) csvwriter . writerow ( headers ) for webuser in periodic_data_list : row = [ webuser [ 'email' ] , int ( time . time ( ) ) ] + [ prop [ 'value' ] for prop in webuser [ 'properties' ] ] csvwriter . writerow ( row ) if settings . S3_ACCESS_KEY and settings . S3_SECRET_KEY and settings . ANALYTICS_IDS . get ( 'KISSMETRICS_KEY' , None ) : s3_connection = tinys3 . Connection ( settings . S3_ACCESS_KEY , settings . S3_SECRET_KEY , tls = True ) f = open ( filename , 'rb' ) s3_connection . upload ( filename , f , 'kiss-uploads' ) os . remove ( filename )