Skip to content

Commit ef25faa

Browse files
authored
Update kaggle_json.py
Fix case-sensitivity bug in dataset name matching
1 parent 94bd3ab commit ef25faa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kaggle_json.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def unformat_bytes(string):
8484
# Old Kaggle Api <1.7
8585
try:
8686
user = dsn.split("/")[0]
87-
dataset = vars(next((d for d in usernames[user] if vars(d)['ref'] == dsn)))
87+
dataset = vars(next((d for d in usernames[user] if vars(d)['ref'].lower() == dsn.lower())))
8888
downloads.append(int(dataset['downloadCount']))
8989
views.append(int(dataset['viewCount']))
9090
sizes.append(int(dataset['totalBytes']))
@@ -94,7 +94,7 @@ def unformat_bytes(string):
9494
except KeyError:
9595
try:
9696
user = dsn.split("/")[0]
97-
dataset = next((d for d in usernames[user] if d.ref == dsn))
97+
dataset = next((d for d in usernames[user] if d.ref.lower() == dsn.lower()))
9898
downloads.append(int(dataset.download_count))
9999
views.append(int(dataset.view_count))
100100
sizes.append(int(dataset.total_bytes))
@@ -174,4 +174,4 @@ def default(self, obj):
174174
print(f'Dumping to file...')
175175
with open('kaggle_stats.json','w') as f:
176176
json.dump(json_dump,f,indent=4,cls=NpEncoder)
177-
print("Done.")
177+
print("Done.")

0 commit comments

Comments
 (0)