![bibデータベースをcsvに変換する](https://rvso.com/image/254708/bib%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%82%92csv%E3%81%AB%E5%A4%89%E6%8F%9B%E3%81%99%E3%82%8B.png)
ある主題に関する参考文献があります (主題は問いません。約 20 個の異なるファイルと約 1000 件のレコードがあります)。これを csv (または Excel/LibreOffice Calc などで開くことができるその他の表形式) に変換する必要があります。
誰かこれ用のツールを挙げられますか?
答え1
.bibファイルを開くジャブレフOpenOffice .csvファイルとしてエクスポートできます。オプションはメニューの下にありますFile
。Export
Jabref
逃げることができるのでプログラムのホームページインストールする必要はありません。ただし、Java が必要です。
答え2
一番良いのは、スクリプト言語、たとえば Python です。あなたがプログラマーかどうかはわかりませんが、各エントリを取得して変換するスクリプトを作成すると、かなり早くできるはずです (python script_file.py
プロンプトに入力するのが怖くなければ)。Python は、ほとんどの Unix OS にデフォルトでインストールされています。
以下は、いくつかのフィールドにアクセスする基本的な Python スクリプトです。
from pybtex.database.input import bibtex
#open a bibtex file
parser = bibtex.Parser()
bibdata = parser.parse_file("myrefs.bib")
#loop through the individual references
for bib_id in bibdata.entries:
b = bibdata.entries[bib_id].fields
try:
# change these lines to create a SQL insert
print(b["title"])
print(b["journal"])
print(b["year"])
#deal with multiple authors
for author in bibdata.entries[bib_id].persons["author"]:
print(author.first(), author.last())
# field may not exist for a reference
except(KeyError):
continue
ニーズに合わせて調整し、必要なフィールドを.csv
ファイルに保存できます。
答え3
bibtexparser を使用した Python バージョンbibtexパーサーそしてパンダ
with open('ref.bib') as bibtex_file:
bib_database = bibtexparser.load(bibtex_file)
df = pd.DataFrame(bib_database.entries)
df.to_csv('ref.csv', index=False)
最小限の動作例:
import bibtexparser
import pandas as pd
bibtex = """@article{ einstein1935can,
title={Can quantum-mechanical description of physical reality be considered complete?},
author={Einstein, Albert and Podolsky, Boris and Rosen, Nathan},
journal={Physical review},
volume={47},number={10},
pages={777},
year={1935},
publisher={APS}}
@inproceedings{sharma2017daniel,
title={DANIEL: A deep architecture for automatic analysis and retrieval of building floor plans},
author={Sharma, Divya and Gupta, Nitin and Chattopadhyay, Chiranjoy and Mehta, Sameep},
booktitle={2017 14th IAPR International Conference on Document Analysis and Recognition (ICDAR)},
volume={1},pages={420--425},year={2017},organization={IEEE}}"""
with open('ref.bib', 'w') as bibfile:
bibfile.write(bibtex)
with open('ref.bib') as bibtex_file:
bib_database = bibtexparser.load(bibtex_file)
df = pd.DataFrame(bib_database.entries)
df.to_csv('ref.csv', index=False)
答え4
Rのもう一つのオプションはパッケージを使うことですbib2df
:
# Install bib2df
install.packages('bib2df')
# Load bib2df
library(bib2df)
# Set path to .bib
# (Example data)
path <- system.file("extdata", "LiteratureOnCommonKnowledgeInGameTheory.bib", package = "bib2df")
# (Alternatively, your own file)
# path <- 'refs.bib'
# Read .bib as a data.frame
df <- bib2df(path)
# Parse the author and editor columns (list columns cannot be saved directly in a csv)
df$AUTHOR <- vapply(df$AUTHOR, paste, collapse = ' and ', '')
df$EDITOR <- vapply(df$EDITOR, paste, collapse = ' and ', '')
# Export to csv
write.csv(df, 'refs.csv')