Ejemplo n.º 1
0
def generate_data():
    try:
        generate_data = pd.DataFrame()
        rows = int(request.form.get('num_rows'))
        anonymize_data = Anonymizer()
        fake_names, fake_first_names, fake_second_names = anonymize_data.fake_name_generator(
            rows)
        generate_data['name'] = fake_names
        generate_data['first_name'] = fake_first_names
        generate_data['last_name'] = fake_second_names
        generate_data['city'] = anonymize_data.get_fake_cities(rows)
        generate_data['country'] = anonymize_data.get_fake_countries(rows)
        generate_data['street_address'] = anonymize_data.get_fake_addresses(
            rows)
        generate_data['url'] = anonymize_data.get_fake_uris(rows)
        generate_data.to_csv('static/generated_data.csv',
                             sep='|',
                             index=None,
                             header=True)
        flash('File successfully generated')
        return render_template('index.html',
                               path_generated_data='static/generated_data.csv')

    except:
        return render_template('index.html')
Ejemplo n.º 2
0
def anonymize():
    try:
        global filepath
        data = pd.read_csv(filepath, sep='|')
        rows, c = data.shape
        selected_name = request.form.get('options_name')
        selected_city = request.form.get('options_city')
        selected_country = request.form.get('options_country')
        selected_address = request.form.get('options_address')
        selected_url = request.form.get('options_uri')

        anonymize_data = Anonymizer()

        if selected_name != 'None':
            fake_names, fake_first_names, fake_second_names = anonymize_data.fake_name_generator(
                rows)
            data[str(selected_name)] = fake_names
        if selected_city != 'None':
            data[str(selected_city)] = anonymize_data.get_fake_cities(rows)
        if selected_country != 'None':
            data[str(selected_country)] = anonymize_data.get_fake_countries(
                rows)
        if selected_address != 'None':
            data[str(selected_address)] = anonymize_data.get_fake_addresses(
                rows)
        if selected_url != 'None':
            data[str(selected_url)] = anonymize_data.get_fake_uris(rows)

        data.to_csv('static/export_data.csv', sep='|', index=None, header=True)
        flash('File successfully anonymized')
        return render_template('index.html',
                               path_anonymize='static/export_data.csv')
    except:
        return render_template('index.html')