Endnote to Bibtex

2017-01-16  by:CAE仿真在線  來源:互聯(lián)網(wǎng)

為了方便將Endnote格式轉(zhuǎn)換為Bibtex格式,特編寫如下程序。

Endnote在轉(zhuǎn)換為Bibtex格式時(shí),缺少label項(xiàng),如果文獻(xiàn)較多的情況下,人工添加是非常費(fèi)時(shí)費(fèi)力的。網(wǎng)上相關(guān)的程序又少。


簽于轉(zhuǎn)出格式為TXT,所以就用MATLAB編寫相關(guān)代碼,實(shí)現(xiàn)批量添加label項(xiàng)。

label項(xiàng)格式為 author-year-pages

如需其它命名格式可自行在代碼中添加,非常簡單。

注意:本程序運(yùn)行時(shí),請先在Endnote輸出文件第一行回車,即@從第二行起。第一行留空。


原文件aa.txt

Endnote to Bibtex

回車第一行留空aa.txt

Endnote to Bibtex




處理

endnote2bibtex('aa.txt')

Endnote to Bibtex













===========源代碼================



% label =Author-year-pages
function endnote2bibtex(filename)

% Author: J.H.Zhujhzhu99@gmail.com
fid = fopen(filename);

% create label
k = 0;
while ~feof(fid)
tline = fgetl(fid);
if ~isempty(strfind(tline,'author'))
author{k} = getstring(tline,'author');
elseif ~isempty(strfind(tline,'year'))
year{k} = getstring(tline,'year');
elseif ~isempty(strfind(tline,'pages'))
pages{k} = getstring(tline,'pages');
end

if sum(tline=='@')
k = k+1;
end
end

for i =1:k
label{i}=[author{i},'-',year{i},'-',pages{i}];
end

k =0;frewind(fid)
fid2 = fopen(['New_',filename],'w+');
while ~feof(fid)
tline = fgetl(fid);
if sum(tline=='@')
k = k+1;
tline = updatelabel(tline,label{k});
end
fwrite(fid2,tline);
fprintf(fid2,'\n');

end
fclose all


function s = getstring(tline,flag)


switch flag
case 'author'
idx_start=findstr(tline,'{');
idx_end = findstr(tline,',');
s = tline(idx_start+1:idx_end(1)-1);
idx = findstr(s,' ');
if ~isempty(idx)
s(idx)=[];
end


case 'year'
idx_start=findstr(tline,'{');
idx_end = findstr(tline,'}');
s = tline(idx_start+1:idx_end-1);
case 'pages'
idx_start=findstr(tline,'{');
idx_end = findstr(tline,'}');
s = tline(idx_start+1:idx_end-1);
end

function s = updatelabel(s,label)

s = [s,label,','];



開放分享:優(yōu)質(zhì)有限元技術(shù)文章,助你自學(xué)成才

相關(guān)標(biāo)簽搜索:Endnote to Bibtex MatLab培訓(xùn) MatLab培訓(xùn)課程 MatLab在線視頻教程 MatLab技術(shù)學(xué)習(xí)教程 MatLab軟件教程 MatLab資料下載 MatLab代做 MatLab基礎(chǔ)知識 Fluent、CFX流體分析 HFSS電磁分析 Ansys培訓(xùn) Abaqus培訓(xùn) 

編輯
在線報(bào)名:
  • 客服在線請直接聯(lián)系我們的客服,您也可以通過下面的方式進(jìn)行在線報(bào)名,我們會及時(shí)給您回復(fù)電話,謝謝!
驗(yàn)證碼

全國服務(wù)熱線

1358-032-9919

廣州公司:
廣州市環(huán)市中路306號金鷹大廈3800
電話:13580329919
          135-8032-9919
培訓(xùn)QQ咨詢:點(diǎn)擊咨詢 點(diǎn)擊咨詢
項(xiàng)目QQ咨詢:點(diǎn)擊咨詢
email:kf@1cae.com