In [8]:
import json
import pandas as pd
import requests
import string
import random

In [20]:
with open('data/data.csv', 'r') as data:
    users_df = pd.read_csv(data)
    
users_df.head()


Out[20]:
email name
0 deborah.mavric@cultureamp.com Deborah
1 kaitlin.meek@cultureamp.com Kaitlin
2 aseel.hamarneh@cultureamp.com Aseel
3 maria@cultureamp.com Maria
4 collin.li@cultureamp.com Collin

In [21]:
def randomStringDigits(stringLength=6):
    """Generate a random string of letters and digits """
    lettersAndDigits = string.ascii_letters + string.digits
    return ''.join(random.choice(lettersAndDigits) for i in range(stringLength))

In [22]:
request_data = []
for index, user in users_df.iterrows():
    request_data.append({
        "username": user['name'],
        "email": user['email'],
        "unique_hash": randomStringDigits(25)
    })

In [23]:
request_data


Out[23]:
[{'username': 'Deborah',
  'email': 'deborah.mavric@cultureamp.com',
  'unique_hash': 'I4HPbxHhXGqPtDp7fflC103AT'},
 {'username': 'Kaitlin',
  'email': 'kaitlin.meek@cultureamp.com',
  'unique_hash': 'G4ZtG1vd1CI68sspP1ti4uHrE'},
 {'username': 'Aseel',
  'email': 'aseel.hamarneh@cultureamp.com',
  'unique_hash': 'WLP8L7XWsb2wf12M0RaZ3H5YI'},
 {'username': 'Maria',
  'email': 'maria@cultureamp.com',
  'unique_hash': 'qFEGYR42lmkSwdmUKvfBFcf2Q'},
 {'username': 'Collin',
  'email': 'collin.li@cultureamp.com',
  'unique_hash': 'DhYOecLUdYIxI9vRQfhfnRMDc'},
 {'username': 'Kevin',
  'email': 'kevin@cultureamp.com',
  'unique_hash': 'tJxzX6EjuDoFJQLj9N1iPwmFT'},
 {'username': 'Josh Berman',
  'email': 'josh.berman@cultureamp.com',
  'unique_hash': 'ARXBMt5OOw518DWKAmoVfTzBN'},
 {'username': 'Nathan',
  'email': 'nathan.ainsworth@cultureamp.com',
  'unique_hash': 'vQLiDS58GpZ7zYSz4XsFu0yux'},
 {'username': 'David',
  'email': 'davidrider@cultureamp.com',
  'unique_hash': 'HjxBlx880QYGIyHjqTBF58oB4'},
 {'username': 'Scott',
  'email': 'scott@cultureamp.com',
  'unique_hash': 't6NftsqAgTELJdkJOGbKfXccS'},
 {'username': 'Ruth',
  'email': 'ruth.madden@cultureamp.com',
  'unique_hash': 'AKgIMXocKh7Kw4JrcxzIUdNQX'},
 {'username': 'SK',
  'email': 'sk@cultureamp.com',
  'unique_hash': 'mWjXmZ8C2pWUnA72PoSu4BXZG'},
 {'username': 'Jeen',
  'email': 'jeen.broekstra@cultureamp.com',
  'unique_hash': 'YS0ulymcnOBilkq7zrFrroJgf'},
 {'username': 'Rizal',
  'email': 'rizal.muthi@cultureamp.com',
  'unique_hash': '3IN5YbFoIhwD9YWnsklDkV20X'},
 {'username': 'Nicholas',
  'email': 'nicholas.godenzi@cultureamp.com',
  'unique_hash': '9awA8ifP1kNbHJFEXm9UTJwAr'},
 {'username': 'Josh',
  'email': 'josh@cultureamp.com',
  'unique_hash': 'BIBih9umsWbIOzZ5UYZKiuikn'},
 {'username': 'Nick',
  'email': 'nick.wolf@cultureamp.com',
  'unique_hash': 'MnaAoml7zSuhB7RfUuOoifaZJ'},
 {'username': 'Ginny',
  'email': 'ginny.fry@cultureamp.com',
  'unique_hash': 'NjqgzbIzsvv1UxMT1MgsU9aeo'},
 {'username': 'Chris',
  'email': 'chris.barrell@cultureamp.com',
  'unique_hash': 'YAGPqrQe00hF8c18x06HZgMJl'},
 {'username': 'Iman',
  'email': 'imanyusuf@cultureamp.com',
  'unique_hash': 'ejqktWwDlGq3k2l0BJnSbsh2Y'},
 {'username': 'Stuart',
  'email': 'stuart.cruickshank@cultureamp.com',
  'unique_hash': 'ntOAPYGvd4SqASwxmNK9jCbYA'},
 {'username': 'Elliott',
  'email': 'elliott.hilaire@cultureamp.com',
  'unique_hash': 'qQVyiCStjlfhavNBzAZH4HsDw'},
 {'username': 'Natalie',
  'email': 'natalie.duffin@cultureamp.com',
  'unique_hash': 'IXYYnuf7xxlGMRqxhHlLff3vk'},
 {'username': 'Elaine',
  'email': 'elaine.rojas@cultureamp.com',
  'unique_hash': 'AibkXCAk0C27rNs9TBcPyzvDi'},
 {'username': 'Amin',
  'email': 'amin.amat@cultureamp.com',
  'unique_hash': '5KlXZgmRM6mxmNJLSEDynu9va'},
 {'username': 'Clara',
  'email': 'clara.mccormack@cultureamp.com',
  'unique_hash': 'iQK79MsGAUwDKY5sAl3UjaKqM'},
 {'username': 'Sid',
  'email': 'sid@cultureamp.com',
  'unique_hash': 'ii2Y8vDrAYQ8lEktutpAkKKC7'},
 {'username': 'Jay',
  'email': 'jay.orsborn@cultureamp.com',
  'unique_hash': '3YPwfm1ywKBkNSm29IWY1URRn'},
 {'username': 'Andriy',
  'email': 'andriy.fedorov@cultureamp.com',
  'unique_hash': 'Aplr5OaaCDYtWZcn1J9wEhB69'},
 {'username': 'Stephanie',
  'email': 'stephanie.sutton@cultureamp.com',
  'unique_hash': 'zYOtLh1jvnKbKs8se2RwSoExI'},
 {'username': 'Sandra',
  'email': 'sandra.berko@cultureamp.com',
  'unique_hash': 'vm9XrgIvw4Yh4yuHmdZJrA8ye'},
 {'username': 'Maggie',
  'email': 'maggie.coughlin@cultureamp.com',
  'unique_hash': 'zmpE6a1Z4cl1oHeUej7wokFNk'},
 {'username': 'Chandler',
  'email': 'chandler.whatley@cultureamp.com',
  'unique_hash': 'PK6Veoo5drBj0tKJN5qmIDiBL'},
 {'username': 'Lyssa',
  'email': 'lyssa.searcy@cultureamp.com',
  'unique_hash': 'g46mJ9sqgPQpVoaXoaPmDRYAd'},
 {'username': 'Zachary',
  'email': 'zachary.fein@cultureamp.com',
  'unique_hash': 'nzrKMDi3euSIGx757mvsi7u2r'},
 {'username': 'Brit',
  'email': 'brit.ferguson@cultureamp.com',
  'unique_hash': 'k6UxJTHx2pm6Z3RJVBoVsutdn'},
 {'username': 'Jacqueline',
  'email': 'jacqueline.purcell@cultureamp.com',
  'unique_hash': 'IAuScL3zNsYIVIPjilhLli8an'},
 {'username': 'Cara',
  'email': 'cara@cultureamp.com',
  'unique_hash': 'DLWwXQCcR4KDVue7NLCvv7Ut6'},
 {'username': 'Katy',
  'email': 'katy@cultureamp.com',
  'unique_hash': 'YrJx0W6spRy4nExyNNcwnhfSC'},
 {'username': 'Kevin',
  'email': 'kevin.campbell@cultureamp.com',
  'unique_hash': 'Y7loT6Dzn2mghFXMuMA4p0aUb'},
 {'username': 'Sangi',
  'email': 'sangi.anantham@cultureamp.com',
  'unique_hash': '6mZzyim7y9xKXVzFLZEGwGbZT'},
 {'username': 'Holly',
  'email': 'holly.foster@cultureamp.com',
  'unique_hash': 'AddJcGdbRtpjp7tBcr4ZplvVj'},
 {'username': 'Hannah',
  'email': 'hannah.wilken@cultureamp.com',
  'unique_hash': 'vqyiuysBWBStWdN9YzCR9ctnt'},
 {'username': 'Muhammad',
  'email': 'muhammad.muthi@cultureamp.com',
  'unique_hash': 'POPwwa8V3S4H3Dfi7xpsJvYog'},
 {'username': 'Melissa',
  'email': 'melissa.bouffler@cultureamp.com',
  'unique_hash': 'UoL2UclCHEeeUiuNTTo2NqlvC'},
 {'username': 'Richard',
  'email': 'richard.anstett@cultureamp.com',
  'unique_hash': 'GF5RfWUeHfPH4zm7QkXBOSVcc'},
 {'username': 'Jason',
  'email': 'jason@cultureamp.com',
  'unique_hash': 'Vata3VrlNByMZWcA9DU7Tqu6q'},
 {'username': 'Hannah',
  'email': 'hannah.spanos@cultureamp.com',
  'unique_hash': 'NW0HSIKMntNEM1r1XGEHzHjwn'},
 {'username': 'Toby',
  'email': 'toby.roger@cultureamp.com',
  'unique_hash': '4UG9SkRCKCWIc2f93Qcj6a0gv'},
 {'username': 'Ruth',
  'email': 'ruth.cosgrove@cultureamp.com',
  'unique_hash': 'kJqytIBxjOhttnzxN0scntNFx'},
 {'username': 'Liliana',
  'email': 'liliana@cultureamp.com',
  'unique_hash': '8KpMnYYxnvIT9H9AIFVz1Z7ff'},
 {'username': 'Roberto',
  'email': 'roberto.anguiano@cultureamp.com',
  'unique_hash': 'AOU01UxozqGVp7bbvNOVfGWB5'},
 {'username': 'Rhiannon',
  'email': 'rhiannon.gaskell@cultureamp.com',
  'unique_hash': 'Qi4ZptNV5okJhDVWrUbDRTgjs'},
 {'username': 'Rachel',
  'email': 'rachel.leonard@cultureamp.com',
  'unique_hash': 'oeiHt6rK5EX0jWEovvC5cJ3NA'},
 {'username': 'David',
  'email': 'david.parry@cultureamp.com',
  'unique_hash': 'FItEGjYWAk048wW8FyfYw6Zgk'},
 {'username': 'Elina',
  'email': 'elina.gault@cultureamp.com',
  'unique_hash': 'GwXjxYPltLu2zx27zlNwDb2Wq'},
 {'username': 'Marie',
  'email': 'marie.taborada@cultureamp.com',
  'unique_hash': 'o8UzU700RuSEDg2dfg8Mz7qzN'},
 {'username': 'Yunfei',
  'email': 'yunfei.ouyang@cultureamp.com',
  'unique_hash': 'Zfh3eZaMcnnIbOPbHzIMZvKDy'},
 {'username': 'Michelle',
  'email': 'michelle.keck@cultureamp.com',
  'unique_hash': 'A0hAYhq9tAUUHbXR82sjlX7ME'},
 {'username': 'Anand',
  'email': 'anand.jameson@cultureamp.com',
  'unique_hash': 'BZjvZTWLjOvFo4D06XZj9xUwo'},
 {'username': 'Rehan',
  'email': 'rehan@cultureamp.com',
  'unique_hash': 'rLX0aIKUMjRmuzczdNuAHQzZ8'},
 {'username': 'Olga',
  'email': 'olga.semeyko@cultureamp.com',
  'unique_hash': 'bKwDt3I44ZvQmJ8B21k12Uo25'},
 {'username': 'James',
  'email': 'james.lovell@cultureamp.com',
  'unique_hash': '6ShVaXI7NfekxqobIDuecCu6c'},
 {'username': 'Jason',
  'email': 'jason.hawes@cultureamp.com',
  'unique_hash': '8tPJIdOVWZJe92SoC2YARzGdt'},
 {'username': 'Eloi',
  'email': 'eloi.lesegretain@cultureamp.com',
  'unique_hash': 'ZUjQVaXB3asUFFLQGMMsTcafY'},
 {'username': 'Rob',
  'email': 'rob.jones@cultureamp.com',
  'unique_hash': '6klfcv7ruRYzpuDD2sS0XpRiX'},
 {'username': 'Didier',
  'email': 'didier@cultureamp.com',
  'unique_hash': 'UntC9qkfGued92e1FLsH3Pt4l'},
 {'username': 'Jacqui',
  'email': 'jacqui.papamatheou@cultureamp.com',
  'unique_hash': 'DPIlXEUosLewL3e6TRiSrFt2z'},
 {'username': 'Caroline',
  'email': 'caroline.setiawan@cultureamp.com',
  'unique_hash': 'o0o7aepLpFFxiUjINln4Zr1ri'},
 {'username': 'Grace',
  'email': 'grace.mole@cultureamp.com',
  'unique_hash': 'cX2utTWHs6r28AiaNwAuEAKog'},
 {'username': 'Carley',
  'email': 'carley.galasso@cultureamp.com',
  'unique_hash': 'WYpO6gGfgk3xX3GaL9mewt6q6'},
 {'username': 'Kavita',
  'email': 'kavitapatel@cultureamp.com',
  'unique_hash': 'cSUKkbBnlsfh9pSuxfpdvtvlZ'},
 {'username': 'David',
  'email': 'david.bauer@cultureamp.com',
  'unique_hash': 'WX8lUyWechkoRnzmiWjIjXOVc'},
 {'username': 'Ann',
  'email': 'ann.estacio@cultureamp.com',
  'unique_hash': 'DvgGcdcMjSwaCzRMpk0Qodfk8'},
 {'username': 'Julio',
  'email': 'julio.feijo@cultureamp.com',
  'unique_hash': 'WJqwxSEk6StN0OzH6bEP54kD0'},
 {'username': 'Nina',
  'email': 'nina.hancock@cultureamp.com',
  'unique_hash': 'Z3OYk4Mp0i71h7pA03rS9ITl7'},
 {'username': 'Kristina',
  'email': 'kristina.lee@cultureamp.com',
  'unique_hash': 'gxD1b2BpBhyZV2USJSspO3Uip'},
 {'username': 'Chatu',
  'email': 'chatu.abeysinghe@cultureamp.com',
  'unique_hash': 'bmcXDpqYYnFZrVEXsSvyn3AJJ'},
 {'username': 'Michele',
  'email': 'michele.gallagher@cultureamp.com',
  'unique_hash': 'pMew6HGam47dMjn3WpLWabrUJ'},
 {'username': 'Fresia',
  'email': 'fresia@cultureamp.com',
  'unique_hash': 'RLnn86ND7Msvf0b79W7UIy6TA'},
 {'username': 'Lexi',
  'email': 'lexi@cultureamp.com',
  'unique_hash': '8TOvFBdAjRx8IGyLLEICR0Jr4'},
 {'username': 'Anna',
  'email': 'anna.gilbert@cultureamp.com',
  'unique_hash': 'PeFKTkE9zwe76c76YaRhYrKWN'},
 {'username': 'Amelia',
  'email': 'ameliachieng@cultureamp.com',
  'unique_hash': 'gxaAg2obzLyHAAo0vxbI70QwI'},
 {'username': 'David',
  'email': 'davido@cultureamp.com',
  'unique_hash': 'meN2fqReYCvRKbLu4RCWovCI1'},
 {'username': 'James',
  'email': 'james.telfer@cultureamp.com',
  'unique_hash': 'x7vVFj4kxw9YlFTXNIlJKiJ7o'},
 {'username': 'Don',
  'email': 'don.buchanan@cultureamp.com',
  'unique_hash': 'qHQKcGnpxmO5nP5aFw7rJCuIB'},
 {'username': 'Kasey',
  'email': 'kasey.koopmans@cultureamp.com',
  'unique_hash': '0OittYlalbQ6WQPkx6AE1ll8E'},
 {'username': 'Timothy',
  'email': 'timothy.lin@cultureamp.com',
  'unique_hash': 'dmQpwtww1ax3acikz3Oa6lmdz'},
 {'username': 'Stacey',
  'email': 'stacey@cultureamp.com',
  'unique_hash': 'FtkBknSufNq4CRt9qqtMsu3T7'},
 {'username': 'Letian',
  'email': 'letian.wang@cultureamp.com',
  'unique_hash': '5bs1YVTmJ1MtAG203PwmZfwUg'},
 {'username': 'Stephanie',
  'email': 'stephanie.brien@cultureamp.com',
  'unique_hash': 'R80wqTdq54ADk5o2Ci63A7RPA'},
 {'username': 'Zoey',
  'email': 'rongzuo@cultureamp.com',
  'unique_hash': 'EwLzDcfFbrkMRDy96OS5szJyd'},
 {'username': 'Sushma',
  'email': 'sushma@cultureamp.com',
  'unique_hash': 'phWEi2N0e7mx3SEm2K5DBbubV'},
 {'username': 'Peter',
  'email': 'peter@cultureamp.com',
  'unique_hash': '5C16YVx0droCFc7KWr0erEljq'},
 {'username': 'Alicia',
  'email': 'alicia.lewis@cultureamp.com',
  'unique_hash': 'xVQF1JJpLH4vUJjREUuXxef2R'},
 {'username': 'Lani',
  'email': 'lani.parrocha@cultureamp.com',
  'unique_hash': 'gX8mpGaQ5q8Jn6LIt2t2IYoaH'},
 {'username': 'Lucy',
  'email': 'lucy.mccue@cultureamp.com',
  'unique_hash': 'NPCEcQhxoNvkBWs52c0LGZSzT'},
 {'username': 'Kristina',
  'email': 'kristina.dorniakwall@cultureamp.com',
  'unique_hash': '56mBCwWMFfgUEB1gjjuxQjeTv'},
 {'username': 'Kevin',
  'email': 'kevin.wiggins@cultureamp.com',
  'unique_hash': 'PhIQ1tisabmvFjtfl25DPYwEU'},
 {'username': 'Jesse',
  'email': 'Jesse@cultureamp.com',
  'unique_hash': 'R5IXkxvnuC2t9vRRVGdPjXUkB'},
 {'username': 'Ashly',
  'email': 'ashly.mohankumar@cultureamp.com',
  'unique_hash': 'M0YwPj1hcYA2O9bjHXeBkPMuq'},
 {'username': 'Priya',
  'email': 'priya@cultureamp.com',
  'unique_hash': 'sohfqmvTwFz4EBYbhm7boWOyc'},
 {'username': 'Nick',
  'email': 'nick.delvecchio@cultureamp.com',
  'unique_hash': 'kkVqF9UamkvBUTDFZq1ZsoicG'},
 {'username': 'Rachelle',
  'email': 'rachelle.santos@cultureamp.com',
  'unique_hash': 'whojb5LzFiRx1356qCG1mpiJk'},
 {'username': 'Sellers',
  'email': 'sellers.webb@cultureamp.com',
  'unique_hash': 'I7TdOzmAp3ot72dFiPv7A0Xox'},
 {'username': 'Jessica',
  'email': 'jessica.occean@cultureamp.com',
  'unique_hash': '4VWNh3KrvZ95hrLFU0wJp7Lmy'},
 {'username': 'Jonathan',
  'email': 'jonathan.hoffman@cultureamp.com',
  'unique_hash': 'tXt8CbpBHyZBhZi2sDxzSSqbI'},
 {'username': 'Andre',
  'email': 'andre.roman@cultureamp.com',
  'unique_hash': 'uWUeADochUi2ZC5eC0iGAKST0'},
 {'username': 'Doug',
  'email': 'doug@cultureamp.com',
  'unique_hash': '8Zxtv9Yzd9tXrDxMz4qgparfN'},
 {'username': 'Andrew',
  'email': 'andrew@cultureamp.com',
  'unique_hash': 'mQ3EJLjNzfWiYF6ce3Ta2wvA7'},
 {'username': 'Stephanie',
  'email': 'stephanie.met@cultureamp.com',
  'unique_hash': 'gc7mmHCGqkxdx8yF35KMT6M8W'},
 {'username': 'Anuradha',
  'email': 'anuradha.satpute@cultureamp.com',
  'unique_hash': 'aPNeVVyNeKdV06eFexuOT79mI'},
 {'username': 'Khalidah',
  'email': 'khalidah.boksh@cultureamp.com',
  'unique_hash': 'qcMVlmyld1caGcG22Bp381gwd'},
 {'username': 'Tolu',
  'email': 'tolu.awoderu@cultureamp.com',
  'unique_hash': 'UjqI6maGjo1UCVlQFVp1Jyuxo'},
 {'username': 'Emily',
  'email': 'emily.orchowski@cultureamp.com',
  'unique_hash': 'tqDKrV5LHLygvNozbEELc9nKv'},
 {'username': 'Dylan',
  'email': 'dylan.bailey@cultureamp.com',
  'unique_hash': 'dRpS16G3LqPWZFkx5D3nzUAIT'},
 {'username': 'Vigeth',
  'email': 'vigeth.tek@cultureamp.com',
  'unique_hash': 'ZeUNkZNgWeyj5HYdEumOHBLuZ'},
 {'username': 'Michel',
  'email': 'michel.edwards@cultureamp.com',
  'unique_hash': 'cxlnKew9CjF1mypHq2B96BpGz'},
 {'username': 'Jessica',
  'email': 'jessica.brannigan@cultureamp.com',
  'unique_hash': 'nVDna8KGBMeyENsvSZenN2SUh'},
 {'username': 'Andy',
  'email': 'andy.mackinlay@cultureamp.com',
  'unique_hash': 'iUk9MUZ5AR16V9svUG86ia1Kv'},
 {'username': 'Rod',
  'email': 'rod@cultureamp.com',
  'unique_hash': 'D1CKSdnnWLrX3CTZLNr52CtVP'}]

In [25]:
api = "http://localhost/api/users/bulk"

try:
    response = requests.post(api, json=request_data)
    print(response)
    print(response.raise_for_status())
except Exception as e:
    print(e)


<Response [201]>
None

In [26]:
new_df = pd.DataFrame(request_data)
new_df.head()


Out[26]:
email unique_hash username
0 deborah.mavric@cultureamp.com I4HPbxHhXGqPtDp7fflC103AT Deborah
1 kaitlin.meek@cultureamp.com G4ZtG1vd1CI68sspP1ti4uHrE Kaitlin
2 aseel.hamarneh@cultureamp.com WLP8L7XWsb2wf12M0RaZ3H5YI Aseel
3 maria@cultureamp.com qFEGYR42lmkSwdmUKvfBFcf2Q Maria
4 collin.li@cultureamp.com DhYOecLUdYIxI9vRQfhfnRMDc Collin

In [27]:
new_df.to_csv('data/new_csv.csv')

In [29]:
api = "http://betterme.cultureamp-labs.com/api/users/bulk"

try:
    response = requests.post(api, json=request_data)
    print(response)
    print(response.raise_for_status())
except Exception as e:
    print(e)


<Response [201]>
None

In [ ]: