Skip to content

Commit 296555c

Browse files
committed
fix for skipping ids with errors
1 parent fb434e0 commit 296555c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

google_export/main.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def get_id_by_name(user_id: str, curl_args):
6464
user_id = json.loads(
6565
output
6666
)
67+
print(user_id)
6768
user_id = user_id[1][31]
6869
return user_id
6970

@@ -115,7 +116,14 @@ def get_awards_by_id(user_id: str | int, key: str, curl_args, timeout, rec_limit
115116

116117

117118
def get_awards(ids: [str | int], key: str, curl_args, timeout, rec_limit=10) -> dict[set]:
118-
awards = {user_id: get_awards_by_id(user_id, key, curl_args, timeout, rec_limit) for user_id in ids}
119+
awards = {}
120+
for user_id in ids:
121+
try:
122+
user_awards = get_awards_by_id(user_id, key, curl_args, timeout, rec_limit)
123+
awards[user_id] = user_awards
124+
except Exception as e:
125+
print(f'Error during processing id = {user_id}, it will be skipped')
126+
print(e)
119127
return awards
120128

121129

@@ -124,7 +132,7 @@ def write_to_local_csv(awards: dict[set], curl_args, fname: str = 'result.csv',
124132
default_columns = [
125133
'id',
126134
'name',
127-
'link',
135+
'url_id',
128136
'public_profile',
129137
'profile created',
130138
]
@@ -142,7 +150,7 @@ def write_to_local_csv(awards: dict[set], curl_args, fname: str = 'result.csv',
142150
row = [
143151
get_id_by_name(user_awards[0], curl_args),
144152
get_name(user_awards[0], curl_args, rec_limit),
145-
get_link(user_awards[0], curl_args, rec_limit),
153+
user_awards[0],
146154
1 if len(user_awards[1]) else 0,
147155
user_awards[1].get('Joined the Google Developer Program'),
148156
]
@@ -193,7 +201,7 @@ def write_to_local_csv(awards: dict[set], curl_args, fname: str = 'result.csv',
193201
else:
194202
print('set ids file or google table input')
195203
q = get_awards(lines, args.key, args.curl_args, args.timeout, args.repeat)
196-
write_to_local_csv(q, args.curl_args, args.output, args.repeat)
204+
write_to_local_csv(q, args.curl_args, args.output, args.repeat,)
197205
if args.google_token and args.table_id and args.sheet_id:
198206
sheets.write_data_to_table(
199207
pandas.read_csv(args.output),

0 commit comments

Comments
 (0)