Skip to content

Instantly share code, notes, and snippets.

@peacing
Created November 9, 2020 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peacing/272164557493d5eebb174fc74decf5d0 to your computer and use it in GitHub Desktop.
Save peacing/272164557493d5eebb174fc74decf5d0 to your computer and use it in GitHub Desktop.
import pandas as pd
import requests
error_list = []
df = pd.read_csv('promos.csv')
for i, row in df.iterrows():
if i % 100 == 0:
print(f'Working on row {i}')
user_id = row['user_id']
url = f'http://internal.services.com/promotions?user_id={user_id}'
r = requests.post(url)
if r.status_code != 200:
error_list.append(user_id)
error_df = pd.DataFrame(error_list, columns=['user_id'])
error_df.to_csv('error_user_ids.csv', index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment