Skip to content

Instantly share code, notes, and snippets.

@rlskoeser
rlskoeser / genizabibliography_sources_ris2csv.py
Last active May 11, 2021 20:02
quick script to get unique sources from Cambridge Geniza bibliography
# pip install pandas rispy
import pandas as pd
import rispy
# download RIS file: https://www.repository.cam.ac.uk/handle/1810/256117
# parse RIS file into entries
with open('genizahbibliography20160203.txt') as bibfile:
entries = rispy.load(bibfile)
@rlskoeser
rlskoeser / django_logentries_export.py
Last active May 19, 2022 20:37
export django admin log entries to csv
import csv
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
# convert action codes to labels
action_label = {ADDITION: 'addition', CHANGE: 'change', DELETION: "deletion"}
with open('/tmp/django-logentries.csv', 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['action_time', 'user', 'content_type', 'object_id', 'change_message', 'action_flag'])
for log in LogEntry.objects.all():
@rlskoeser
rlskoeser / count_pgptxtfiles.sh
Last active January 9, 2024 21:57
shell script to count number of transcription and text files and documents in pgp-text git repo over time
#!/bin/bash
# based on https://blog.benoitblanchon.fr/git-file-count-vs-time/
OUTPUT=stats.csv
# create output file with a CSV header
# echo "date;transcription_count;transcribed_documents;translation_count;translated_documents" > $OUTPUT
echo "date,transcriptions,transcribed_documents,translations,translated_documents" > $OUTPUT