; docformat = 'rst' ; ; NAME: ; exportBiblio ; PURPOSE: ; Export a publication record into many text files ; ;+ ; :Description: ; Export a publication record into many text files ; ; :Categories: ; Bibliography ; ; :Params: ; bib: in, required, type=structure ; A structure with the bibliographic entries. Fields are:: ; type : Type of entry (refereed|invited|contributed|citations) ; ads : Ads Unique Identifyer ; id : Unique Id ; year : Year of publication ; month : Month of publication ; journal : Journal full name ; abbrev : Journal abbreviation ; volume : Volume ; issue : Issue ; page : Article pages ; title : Article title ; first : First author family name ; doi : Article DOI ; authors : Full list of authors ; ; :Keywords: ; refereed: in, optional, type=boolean, default=1 ; Only return refereed publications. ; contributed: in, optional, type=boolean, default=1 ; Only return non-refereed publications. ; ; :Examples: ; ; :Uses: ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in July 2016, B. Carry (OCA) ;- pro exportBiblio, bib, author=author, cwd=cwd ;tbd: add author param, and chech bib.first vs author ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Verify Input Syntax ----------------------------------------------------------------- if not keyword_set(bib) then begin message, /ioError, 'Syntax error: exportBiblio, bib' return endif ;--I.2-- Number & Types of Entries ----------------------------------------------------------- nbBib = n_elements( bib ) uType = uniq( bib.type, sort(bib.type) ) nbtype = n_elements(uType) idRef = where( strCmp(bib.type,'refereed',/fold), nbRef ) idCon = where( strCmp(bib.type,'contributed',/fold), nbCon ) ;--I.3-- Current Working Directory ----------------------------------------------------------- if not keyword_set(cwd) then cwd='./' ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Refereed Articles -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if nbRef ge 1 then begin fileList = strarr(nbRef) for kRef=0, nbRef-1 do begin ;--II.1-- Select Current Local Entry ------------------------------------------------------- loc = bib[ref[kRef]] ; print, loc.id ; stop ;--II.2-- Open File for Export ------------------------------------------------------------- fileName = loc.id+'.txt' fileList[kRef] = fileName openW, id, cwd+fileName, /get_lun ;--II.3-- Write Bibliographic Fields ------------------------------------------------------- printf, id, 'ads = '+ loc.ads printf, id, 'year = '+ loc.year printf, id, 'month = '+ loc.month printf, id, 'published = 1' printf, id, 'first = 0' printf, id, 'journal = '+ loc.journal printf, id, 'volume = '+ loc.volume printf, id, 'pages = '+ loc.page printf, id, 'author = '+ loc.authors printf, id, 'title = '+ loc.title printf, id, 'pdf = '+ loc.id+'.pdf' printf, id, 'graph = '+ loc.id+'.png' printf, id, 'abstract = '+ loc.abstract ;--II.4-- Close File ----------------------------------------------------------------------- close, id free_lun, id endfor ;--II.5-- Write Summary File ----------------------------------------------------------------- forprint, fileList, format='(A-)', textout=cwd+'list.ref', /NoComment, /Silent endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- III -- Contributed Presentations at Conferences -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; if nbCon ge 1 then begin fileList = strarr(nbCon) for kCon=0, nbCon-1 do begin ;--III.1-- Select Current Local Entry ------------------------------------------------------ loc = bib[idCon[kCon]] ;--III.2-- Open File for Export ------------------------------------------------------------ fileName = loc.id fileList[kCon] = fileName openW, id, cwd+fileName+'.txt', /get_lun ;--III.3-- Write Bibliographic Fields ------------------------------------------------------ printf, id, 'ads = '+ loc.ads printf, id, 'year = '+ string(loc.year,format='(I4)') printf, id, 'month = '+ loc.month printf, id, 'first = 0' printf, id, 'meeting = '+ loc.journal authLine='author = '+(*loc.authors)[0] nbAuth = n_elements(*loc.authors) for kAuth=1, nbAuth-2 do authLine+=', '+(*loc.authors)[kAuth] authLine+=' & '+(*loc.authors)[nbAuth-1] printf, id, authLine printf, id, 'title = '+ loc.title printf, id, 'pdf = '+ loc.id+'.pdf' printf, id, 'graph = '+ loc.id+'.png' ; printf, id, 'abstract = '+ loc.abstract ; help, loc ;stop ;--III.4-- Close File ---------------------------------------------------------------------- close, id free_lun, id endfor ;--III.5-- Write Summary File ---------------------------------------------------------------- forprint, fileList, format='(A-)', textout=cwd+'list.con', /NoComment, /Silent endif end