; docformat = 'rst' ; ; NAME: ; readBiblio ; PURPOSE: ; Read a list of bibliographic references from local ascii file. ; ;+ ; :Description: ; Read a list of bibliographic references from local ascii file. ; ; :Categories: ; Bibliography ; ; :Params: ; file: in, required, type=string ; Path to a local file with bibliography information. ; ; :Keywords: ; ; :Returns: A structure with the bibliographic entries. Fields are:: ; ; :Examples: ; ; :Uses: ; readcol ; ; :Author: ; B.Carry (OCA) ; ; :History: ; Change History:: ; Written in October 2015, B. Carry (OCA) ;- function readBiblio, file ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- I -- Initialization And Input Verification -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; COMPILE_OPT hidden, idl2 ;--I.1-- Verify Input Syntax ---------------------------------------------------------- if not keyword_set(file) then begin message, /IOERROR, 'Syntax error: bib = readBiblio( file )' return, -1 endif ;--I.2-- Test File for Reading -------------------------------------------------------- if not file_test(file,/read) then begin message, /IOERROR, 'Bibliography file cannot be found: '+strtrim(file,2) return, -2 endif ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--- TAG --- II -- Read the Bibliographic Reference File -----------------------; ;-----------------------------------------------------------------------------------------------; ;-----------------------------------------------------------------------------------------------; ;--II.1-- Blind Read of the File ------------------------------------------------------- readcol, file, type, ads, id, title, $ format='(A,A,A,A)', delimiter=',',/silent nbBib=n_elements(ads) ;--II.2-- Build Output Structure ------------------------------------------------------- empty={type:'', ads:'', id:'', year:0, author:'', title:''} bib = replicate(empty, nbBib) ;--II.3-- Fill Output Structure -------------------------------------------------------- bib.type = strtrim(type,2) bib.ads = strtrim(ads,2) bib.id = strtrim(id,2) bib.title = strtrim(title,2) for kBib=0, nbBib-1 do begin split=strsplit( id[kBib], '-', /extract, count=nbField ) bib[kBib].year = round(float(split[0])) bib[kBib].author = split[nbField-1] endfor return, bib end