%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       csvReader                         %
%       26/07/2009                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [header, dates, data] = csvreader()
clc
close all

disp('*******************************************');
disp('*       csvReader                         *');
disp('*       26/07/2009                        *');
disp('*******************************************');

%get the file
[fileName, pathName] = uigetfile('*.csv', 'Select .csv file...');

if isequal(fileName,0) || isequal(pathName,0)
    disp('User Cancelled...');
else
    fid = fopen(fullfile(pathName,fileName));
    disp(['File: ',fullfile(pathName,fileName)]);
    header = fgetl(fid);
    c  = textscan(fid,'%s%s%s%s%s%s%s','Delimiter',',');
    for i = 2:length(c)
        data(:,i-1) = str2double(c{i});    
    end
    dates = c{1};
    
    % file contents is in the following:
    header;
    dates;
    data;
    
    disp('Finished Reading File...');
    
end
end



