Skip to content

Instantly share code, notes, and snippets.

View DominicBM's full-sized avatar

Dominic Byrd-McDevitt DominicBM

View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"num"
"type"
"naId"
"authority"
"authority.topicalSubject"
"authority.topicalSubject.naId"
"authority.topicalSubject.termName"
"authority.topicalSubject.isPreferred"
"authority.topicalSubject.isUnderEdit"
"authority.topicalSubject.isReference"
import requests, json, csv, re, string, argparse
logfile = 'fields.csv'
offset = 0
while offset < 6000 :
r = requests.get('https://catalog.archives.gov/api/v1?type=topical-subject&rows=200&offset=' + str(offset)).text
r = re.sub('( *)(\"@user.*?)\"\$\"',r'\1\2\n\1"$"', r)
m = string.split(r, '\n')
import requests, json, csv
r = json.loads(requests.get('https://catalog.archives.gov/api/v1?naIds=10534724').text)
for key0 in r['opaResponse']['results']['result'][0].keys():
print key0
try:
for key1 in r['opaResponse']['results']['result'][0][key0].keys():
print key0 + '.' + key1
try:
import requests, json, argparse, random, os, Tkinter
parser = argparse.ArgumentParser()
parser.add_argument('--naid', dest='naid', metavar='NAID',
action='store')
parser.add_argument('--tag', dest='tag', metavar='TAG',
action='store')
parser.add_argument('--user', dest='user', metavar='USER',
action='store')
import ttk, json, requests, PIL, os
from Tkinter import *
from ttk import Frame, Style
from PIL import Image, ImageTk
def topic(*args):
topics = topictext.get()
image = json.loads(requests.get('https://uat.research.archives.gov/api/v1/?resultTypes=object&rows=200&description.item.scopeAndContentNote=' + topics).text)
total = image['opaResponse']['results']['total'] - 1
if total > 199 :
{
"opaResponse":{
"header":{
"@status":"200",
"time":"2015-03-12T23:33:56.039Z",
"request":{
"@action":"save",
"@path":"\/api\/v1\/id\/7000802\/tags",
"format":"json",
"pretty":true,
import requests, json, os, csv, argparse
parser = argparse.ArgumentParser()
parser.add_argument('--file', dest='file', metavar='FILE',
action='store')
args = parser.parse_args()
file = args.file
newfile = 'NAIDs - ' + args.file