bib 데이터베이스를 csv로 변환

bib 데이터베이스를 csv로 변환

나는 어떤 주제에 대한 참고문헌을 가지고 있습니다(주제가 무엇인지는 중요하지 않습니다. 약 20개의 파일과 약 1000개의 레코드가 있습니다). csv(또는 Excel/LibreOffice Calc 등에서 열 수 있는 다른 테이블 형식)로 변환해야 합니다.

누구든지 이에 대한 도구 이름을 지정할 수 있습니까?

답변1

.bib 파일을 다음에서 엽니다.야브레프OpenOffice .csv 파일로 내보냅니다. 메뉴에서 옵션을 찾으세요 File.Export

Jabref_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 버전bibtexparser그리고팬더

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

관련 정보