Skip to content

Instantly share code, notes, and snippets.

View jalperin's full-sized avatar

Juan Pablo Alperin jalperin

View GitHub Profile
@jalperin
jalperin / get_works.py
Created June 26, 2014 20:45
Fetch all works for a CrossRef DOI prefix from the CrossRef API
"""get_works.py: Fetch all the works from CrossRef API by DOI prefix."""
__author__ = "Juan Pablo Alperin (@juancommander)"
import re
import urllib, urllib2
import simplejson as json
from time import sleep
import datetime
@jalperin
jalperin / mendeley_oauth2_example.py
Last active November 6, 2022 10:44
Example of how to access the Mendeley OAuth2 API
# -*- 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 = ''
@jalperin
jalperin / mmdcitation_to_pandoc.py
Last active August 29, 2015 14:00
Convert MultiMarkdown (MMD) citations to Pandoc citations
import re
import fileinput
def change_references(s):
# inline citations are always single author, take them out of []
s = re.sub(r'\[#([^\]]+);\]', '@\\1', s)
n = 1
# replace all the "," in [#xxx,xxx,xxx,xxx] with ,@
while ( n > 0 ):
@jalperin
jalperin / update_doi.py
Created March 27, 2014 19:54
This is some hacked together code that wont run on its own (as its part of a largest script that uses python Pandas). But this shows the logic and queries that can be made from the crossref API to search for a DOI based on some metadata and then validate it using some sanity checks.
import json
import urllib, urllib2
import urlparse
from unidecode import unidecode
CROSSREF_API_DOI = 'http://search.crossref.org/dois?'
def verify_doi(doi,article):
doi_query_url = 'http://search.crossref.org/dois?' + urllib.urlencode({'q': doi})
response = json.loads(urllib2.urlopen(doi_query_url).read())
{
"metadata": {
"name": "Final Assignment"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.