bibデータベースをcsvに変換する

bibデータベースをcsvに変換する

ある主題に関する参考文献があります (主題は問いません。約 20 個の異なるファイルと約 1000 件のレコードがあります)。これを csv (または Excel/LibreOffice Calc などで開くことができるその他の表形式) に変換する必要があります。

誰かこれ用のツールを挙げられますか?

答え1

.bibファイルを開くジャブレフOpenOffice .csvファイルとしてエクスポートできます。オプションはメニューの下にありますFileExport

Jabref_エクスポート

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')

関連情報