Skip to content

Instantly share code, notes, and snippets.

View hpiwowar's full-sized avatar

Heather Piwowar hpiwowar

View GitHub Profile
@hpiwowar
hpiwowar / children_of_library_science.py
Last active February 9, 2022 16:51
Sample code to get the children concepts of Library Science, using the OpenAlex API
import requests
api_response = requests.get("https://api.openalex.org/concepts?filter=ancestors.id:C161191863")
parsed_response = api_response.json()
result_list = parsed_response["results"]
for result in result_list:
print(result["display_name"], result["id"], result["level"])
@hpiwowar
hpiwowar / Unpaywall Journals Exploration.ipynb
Last active February 10, 2020 01:19
blog_num_journals.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hpiwowar
hpiwowar / manuscript.ipynb
Last active October 7, 2019 03:31
manuscript.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hpiwowar
hpiwowar / downloads.ipynb
Last active September 25, 2019 00:30
downloads.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hpiwowar
hpiwowar / google_sheets_from_heroku.py
Last active February 5, 2023 19:22
read and write to a google spreadsheet from heroku using python
import os
import json
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# based on https://www.twilio.com/blog/2017/02/an-easy-way-to-read-and-write-to-a-google-spreadsheet-in-python.html
# read that file for how to generate the creds and how to use gspread to read and write to the spreadsheet
# use creds to create a client to interact with the Google Drive API
scopes = ['https://spreadsheets.google.com/feeds']
def get_row_iterator_jsonl_gz(filename, log_period_s=5): # log_period_s=None for no logging
import gzip
import time
import os.path
import json
# this is the compressed file size
# looks like the gzip format only defines the uncompressed file size modulo 2^32
file_size = os.path.getsize(filename)
www.ncbi.nlm.nih.gov | 3482858
arxiv.org | 655343
www.persee.fr | 200061
ftp.ncbi.nlm.nih.gov | 130586
biblio.ugent.be | 23772
cds.cern.ch | 21790
repositorio.unesp.br | 19220
hal.archives-ouvertes.fr | 15174
orbit.dtu.dk | 11655
www.econstor.eu | 10176
# -*- coding: utf-8 -*-
#!/usr/bin/env python
### Example code to access the Mendeley OAuth2 API
### Author: Juan Pablo Alperin
import requests
import requests.auth
import urllib
CLIENT_ID = ''
CLIENT_SECRET = ''
@hpiwowar
hpiwowar / bibtex_to_csv.py
Created July 1, 2011 22:20
For exporting bibtex info into csv for running stats
#!/usr/bin/env python
# Initially written by Heather Piwowar, June 2011
# Public domain: have at it!
# For exporting bibtex info into csv for running stats
import csv
import re
from pybtex.database.input import bibtex as bibtex_in
from pybtex.database.output import bibtex as bibtex_out
from operator import itemgetter, attrgetter
@hpiwowar
hpiwowar / sample_bibtex.py
Created June 23, 2011 23:25
For stratified sampling of bibtex records
#!/usr/bin/env python
# Initially written by Heather Piwowar, June 2011
# Public domain: have at it!
# For stratified sampling of bibtex records
import random
import math
import re
from collections import defaultdict