function genericLookup(inputFile, lookupTable)
% takes a text file of one item per line, and writes out a textfile (one item per line) of the corresponding entry from the lookup table. Expected input structure is double-quoted comma-separated UTF-8 text.
%
% DEPENDS: none
% AUTHOR: Daniel McCloy (drmccloy@uw.edu)
% LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 3.0 LICENSE: http://creativecommons.org/licenses/by/3.0/

%% INPUTS
% expected input structure is double-quoted & comma-separated UTF-8 text.
[lt1 lt2] = textread(lookupTable, '%q %q', 'delimiter', ',');
lt = containers.Map(lt1,lt2);
clear lt1 lt2
    
% use this first line if your input file has line numbers:
%[~,inp]= textread(inputFile, '%u %q', 'delimiter', ',');
inp= textread(inputFile, '%q', 'delimiter', ',');

%% LOOKUP & WRITE OUT
% preallocate
oup = cell(length(inp),1);

% open output file
outPath = [inputFile '_LOOKUP.csv'];
fout = fopen(outPath, 'a+');  % open file

for n=1:length(inp)
    oup{n} = lt(inp{n});
    fprintf(fout, '%s\n', oup{n});
end
clear n

% close file & clean up
fclose(fout);
clear inp oup lt fout
