예제 #1
0
redshift_credentials_user = config['AWS_REDSHIFT']['USER']
redshift_credentials_password = config['AWS_REDSHIFT']['PASSWORD']

user = config['LIME_CONFIG']['LIME_USER']
key = config['LIME_CONFIG']['LIME_KEY']
url = config['LIME_CONFIG']['LIME_API_URL']
sid = config['LIME_CONFIG']['LIME_SID_ORDER']
token = config['LIME_CONFIG']['LIME_TOKEN_BASE']

DATE_NOW = datetime.datetime.now().strftime('%Y%m%d')

# Build the API
lime = Api(url, user, key)
export_res_token = lime.export_responses(sid=sid,
                                         status='all',
                                         heading='code',
                                         response='short',
                                         fields='')
OUTPUT_PATH = PATH + "/lime_export_{s}.txt".format(s=sid)

with open(OUTPUT_PATH, 'w') as outfile:
    json.dump(export_res_token, outfile)

df = pandas.read_json(OUTPUT_PATH)
ds = pandas.DataFrame()
for row in df.index:
    data = pandas.DataFrame(
        df.loc[row].loc['responses']).transpose().reset_index(drop=False)
    ds = ds.append(data, ignore_index=True)

req_cols = ['id', 'datestamp', 'q01', 'q03', 'q06']
예제 #2
0
redshift_credentials_password = config['AWS_REDSHIFT']['PASSWORD']

user = config['LIME_CONFIG']['LIME_USER']
key = config['LIME_CONFIG']['LIME_KEY']
url = config['LIME_CONFIG']['LIME_API_URL']
sid = config['LIME_CONFIG']['LIME_SID_RETURN']
token = config['LIME_CONFIG']['LIME_TOKEN_BASE']

DATE_NOW = datetime.datetime.now().strftime('%Y%m%d')

# Build the API
lime = Api(url, user, key)

export_res_token = lime.export_responses(sid=sid,
                                         status='',
                                         heading='',
                                         response='',
                                         fields='')
OUTPUT_PATH = PATH + "/lime_export_{s}.txt".format(s=sid)

with open(OUTPUT_PATH, 'w') as outfile:
    json.dump(export_res_token, outfile)

d = pandas.read_json(OUTPUT_PATH)
df = pandas.DataFrame()
for row in d.index:
    data = pandas.DataFrame(
        d.loc[row].loc['responses']).transpose().reset_index(drop=False)
    df = df.append(data, ignore_index=True)

req_cols = [
예제 #3
0
import base64  # para encodear la subida de surveys

# demo de limesurvey
usuario = 'admin'
clave = 'test'
url = 'http://demo.limesurvey.org/index.php?r=admin/remotecontrol'

lime = Api(url, usuario, clave)

for e in lime.list_surveys():

    propiedades = lime.get_survey_properties(e[0], settings='["active"]')

    if propiedades['active'] == 'Y':
        print "La encuesta %s esta activa" % e[0]
        summary = lime.get_summary(e[0])

        if summary['full_responses'] != '0':
            print summary
            datos = lime.export_responses(e[0])

            if datos is not None:
                decoded_string = base64.b64decode(datos)
                print decoded_string

                break

    else:
        print "La encuesta %s no esta activa" % e[0]
        # print lime.delete_survey(e[0])