Benutzer:Erzbischof/LibraryThing

aus Wikipedia, der freien Enzyklopädie
Zur Navigation springen Zur Suche springen

Kleines LibraryThing-Datenexport-Helferlein

[Bearbeiten | Quelltext bearbeiten]

Ermöglicht Export in BibTeX-Format. Es ist vermutlich fehleranfällig, falsch und gefährlich, ich habe noch nicht vorher in Python programmiert.

Name: tab2bib Funktion: Wrapper-Shellskript, ruft tab2bib.py und Zeichenssatzprogram recode auf. #!/bin/bash cp $1.xls $1.tmp recode UTF-16..Latex $1.tmp #recode UTF-16..u8 $1.tmp python tab2xml.py < $1.tmp > $1.bib #recode -d u8..LaTex $1.bib

Name: tab2bib.py Funktion: Python-Skript, wandelt tabstoppgetrennte Exportdatei von Library Thing in BibTeX-Format um. import csv, sys, re #(nr) (colum) #0 book id #1 title #2 author (first, last) #3 author (last, first) #4 other authors #5 publication #6 date #7 ISBN #8 series #9 source #10 language1 #11 language2 #12 original language #13 LC Call No. #14 Dewey Decimal #15 BCID #16 date entered #17 date entered #18 date entered #19 date entered #20 tags #21 rating #22 review #23 summary #24 comments #25 encoding mre = re.compile("[\w]*") try: header = sys.stdin.readline() for line in sys.stdin: row = line.split('\t') short = mre.findall(row[3]+" " + row[1]) print "@book{", short[0]+row[6], "," if len(row[4]) > 0 : zwi = row[3]+ ", " + row[4] else: zwi=row[3] if len(row[1]) > 0 : print "\ttitle = {", row[1], "}," if len(row[3]) > 0 : print "\tauthor = {",zwi,"}," if len(row[5]) > 0 : print "\tpublisher = {", row[5], "}," if len(row[6]) > 0 : print "\tyear = {", row[6], "}," if len(row[7]) > 2 : print "\tisbn = {", row[7][1:-1], "}," #isbn wrapped by [] if len(row[8]) > 0 : print "\tkeywords = {", row[8], "}," if len(row[13]) > 0 : print "\tlccn = {", row[13], "}," print "}\n" except csv.Error, e: sys.exit('%s' % e)