Skip to content

Instantly share code, notes, and snippets.

View hpiwowar's full-sized avatar

Heather Piwowar hpiwowar

View GitHub Profile
@hpiwowar
hpiwowar / plot.summary.formula.response.CIs.R
Created May 30, 2011 15:10
Plots Hmisc summary formula responses with confidence intervals
### Heather Piwowar
# Modifications to add confidence intervals added by Heather Piwowar
# Based on dotchart2{Hmisc}
dotchart2.CIs =
function (data, labels, groups = NULL, gdata = NA, horizontal = TRUE,
pch = 16, xlab = "", ylab = "", auxdata, auxgdata = NULL,
auxtitle, lty = if (.R.) 1 else 2, lines = TRUE, dotsize = 0.8,
cex = par("cex"), cex.labels = cex, cex.group.labels = cex.labels *
1.25, sort. = TRUE, add = FALSE, dotfont = par("font"),
@hpiwowar
hpiwowar / ASIST2011_stats.R
Created May 30, 2011 15:15
Stats for the analysis and graphics in Piwowar ASIS&T 2011 submission "Finding the hold-outs"
### Heather Piwowar
### MIT open license.
### blog post about interm results:
library(rms)
# if true, draw figures on screen instead of in a file
SCREEN=TRUE
# set to ".eps" or ".png"
@hpiwowar
hpiwowar / wos_txt_to_bibtex.py
Created June 23, 2011 23:24
For converting ISI Web of Science tab-delimited exports into bibtex format
#!/usr/bin/env python
# Initially written by Heather Piwowar, June 2011
# Public domain: have at it!
# For converting ISI Web of Science tab-delimited exports into bibtex format
import csv
import glob
import random
from collections import defaultdict
import codecs
@hpiwowar
hpiwowar / annotate_bibtex.py
Created June 23, 2011 23:25
For annotating bibtex files using article info from customized spreadsheets
#!/usr/bin/env python
# Initially written by Heather Piwowar, June 2011
# Public domain: have at it!
# For annotating bibtex files, pulling in article info from customized spreadsheets
import csv
import re
import codecs
from pybtex.database.input import bibtex as bibtex_in
from pybtex.database.output import bibtex as bibtex_out
@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
@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
# -*- 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 = ''
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
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)
@hpiwowar
hpiwowar / google_sheets_from_heroku.py
Last active February 15, 2025 12:43
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']