Created
April 3, 2023 16:54
-
-
Save caseydm/0f77c9261376109312badcde82a6c1a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from app import db | |
with open("publishers_image_thumbnail_urls.csv", "r") as f: | |
reader = csv.reader(f) | |
for row in reader: | |
publisher_id = int(row[0].replace("https://openalex.org/P", "")) | |
image_thumbnail_url = row[2] | |
db.session.execute('UPDATE mid.publisher SET image_thumbnail_url = :image_thumbnail_url WHERE publisher_id = :publisher_id', {"image_thumbnail_url": image_thumbnail_url, "publisher_id": publisher_id}) | |
db.session.commit() | |
print(f"Updated {publisher_id} with {image_thumbnail_url}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment