bibtex - urldate 형식 변경

bibtex - urldate 형식 변경

인용 관리자 Citavi를 사용하는데 문제가 있습니다. Citavi 형식으로만 내보낼 수 있습니다 urldate = {dd.mm.yyyy}. 그러나 Bibtex에는 형식이 필요합니다 urldate = {yyyy-mm-dd}. 내 경우에는 참고문헌의 모든 날짜를 수동으로 변경하는 것이 현실적이지 않습니다. 항목이 많고 내보낸 후 다시 실행해야 하기 때문입니다.

예를 들어 내 bibtex 항목은 다음과 같습니다.

@Misc{FAO.2011,
  Title                    = {{FAOSTAT: Food balance sheet}},
  Author                   = {FAO},
  Year                     = {2011},
  Address                  = {Rome},
  Url                      = {http://faostat3.fao.org/download/FB/FBS/E},
  Urldate                  = {15.1.2014}
}

그런 다음 BibTex로 컴파일하면 다음과 같은 경고가 나타납니다.

Package biblatex Warning: Biber reported the following issues
(biblatex) with 'FAO.2011':
(biblatex) - Datamodel: Entry 'FAO.2011' (literature.bib): Inval
id format '15.1.2014' of date field 'urldate' - ignoring.

urldate형식으로 읽는 Bibtex의 형식을 변경할 수 있는 방법이 있습니까? urldate = {dd.mm.yyyy}아니면 어떻게든 변환할 수 있습니까 urldate = {yyyy-mm-dd}?

인터넷에서 검색했는데 이 문제에 대한 해결책을 찾지 못했습니다. Citavi의 특정 문제인 것 같습니다. 안타깝게도 Citavi는 사용자 정의가 불가능합니다.

내 질문은 다음과 유사합니다.biblatex/biber 경고를 제거하기 위해 참고문헌 필드[예: "urldate"]를 무시합니다.. 그러나 이 주제에서는 내 문제에 대한 해결책이 제공되지 않았습니다. 이 경우에는 urldate필요하지 않아 그냥 무시되었기 때문입니다. 하지만 나는 주어야 한다 urldate.

답변1

Giacomo의 피드백 덕분에 이 특정 문제에 대한 또 다른 해결책을 찾았습니다.

문제는 Citavi와 더 관련이 있으며 Citavi는 LaTeX만큼 명확하거나 투명하지 않습니다. 비슷한 문제가 발생할 수 있는 다른 사람들이 나중에 참고할 수 있도록: Citavi가 날짜를 형식으로 제공하도록 요청하지만 urldate={dd.mm.yyyy}로 입력할 수 있습니다 urldate = {yyyy-mm-dd}. 수출에는 문제가 없습니다. 이상하게도 하나의 항목만 변경하면 다른 모든 항목도 그에 따라 내보내집니다. 더 일찍 시도하지 않은 내 잘못입니다. 더 일찍 시험해 봤어야 했는데.

답변2

패키지를 사용하는 경우 biblatex사용할 수 있습니다

\DeclareSourcemap{
    \maps{
        \map[overwrite]{
            \step[fieldsource=urldate,
            match=\regexp{([0-9]{2})\.([0-9]{2})\.([0-9]{4})},
            replace={$3-$2-$1},
            final]
        }
    }
}

urldate입력 *.bib파일 의 필드 형식을 다시 지정하려면 서문에서

답변3

BibTeX에서 형식을 강제하기 위해 이중 중괄호를 사용합니다. 예:

Urldate  = {{15/01/2014}}

답변4

나는 urldate의 형식을 변경하는 작은 Python 스크립트를 작성했습니다. .bib 파일을 이 스크립트와 동일한 디렉토리에 배치하고 이름을 "quellen.bib"로 지정한 다음 스크립트를 실행하십시오. "changedFile.bib"라는 새로운 형식의 파일이 나타납니다.

import re

file = open("quellen.bib","r");
fileChanged = open("changedFile.bib","w");
pattern = re.compile("([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})");

for line in file:
    if "urldate =" in line and pattern.search(line):
        #save end of line to add it later to the modified date
        endline = line[line.index('}')+1:len(line)];
        date = line[line.index('{')+1:line.index('}')];
        month = int(date[0:date.index('/')]);
        date = date[date.index('/')+1:len(date)];
        day = int(date[0:date.index('/')]);
        date = date[date.index('/')+1:len(date)];
        year = int(date);
        if month > 12:
            # check if month and day are reversed
            temp = day;
            day = month;
            month = temp;
        # check if every value is ledgit
        if(month > 0 and month < 13 and day >0 and day < 32 and year > 1000):
            if(month<10):
                #add 0 if month or day is less then 10
                month = "0"+str(month);
            if(day<10):
                day = "0"+str(day);    
            fileChanged.write(" urldate = {"+ str(year)+"-"+str(month)+"-"+str(day)+"}"+endline);
        else:
            print("something is wrong with this line: ");
            print("day: ",day,"montH: ",month, "year: ",year);
            print(line);
    else:
        fileChanged.write(line);
file.close;
fileChanged.close;

    

관련 정보