CSV ファイル、テキスト ファイル、および Word ファイルがあり、大量の参考文献を .bib ファイルにエクスポートします。できればカスタム オーダーを定義してください。
私が知りたいのは、Python を使用してこの情報を .bib ファイルに変換する最良の方法は何ですか?
Text を XML に変換してから .bib に変換していますか? または、CSV ファイルを読み込んで列を反復処理し、列ごとに書き込みますか?
CSV をロードし、各列をリストとして取得するためのスクリプトを作成しましたが、.bib に変換する方法を解決できません。
まとめたコードは次のとおりです。
import csv
import pandas
import bibtexparser
from bibtexparser.bparser import BibTexParser
from bibtexparser.customization import *
colnames = ['AUTHORS', 'TITLE', 'EDITOR']
data = pandas.read_csv('file.csv', names=colnames, delimiter =r";", encoding='latin1')
list1 = list(data.AUTHORS)
def customs(record):
record = type(record)
record = author(record)
record = editor(record)
return record
with open('123.bib','w') as bibtex_file:
parser = BibTexParser()
parser.customization = customs