Skip to content
Snippets Groups Projects
Commit c976d144 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix CSV loading under Octave with IO package.

Also, for people who don't have the IO package, always use the fallback
code (even when the first line is <= 4096 bytes long).

Ref #2
parent 7ff2dc60
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ function [freq, init, data, varlist] = load_csv_file_data(file) ...@@ -16,7 +16,7 @@ function [freq, init, data, varlist] = load_csv_file_data(file)
% names. Similarly, if the first column does not contain dates, then % names. Similarly, if the first column does not contain dates, then
% freq will be 1 and init will be year 1. % freq will be 1 and init will be year 1.
% Copyright (C) 2012-2014 Dynare Team % Copyright (C) 2012-2015 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -44,16 +44,11 @@ if isoctave ...@@ -44,16 +44,11 @@ if isoctave
fid = fopen(file, 'r'); fid = fopen(file, 'r');
firstline = fgetl(fid, 4097); firstline = fgetl(fid, 4097);
fclose(fid); fclose(fid);
if length(firstline) < 4097 if length(firstline) < 4097 && user_has_octave_forge_package('io')
if ~user_has_octave_forge_package('io') A = csv2cell(file);
try [data, T, L] = parsecell(A);
pkg load io withvars = L.numlimits(2,1) > L.txtlimits(2,1);
catch withtime = L.numlimits(1,1) > L.txtlimits(1,1);
error(['The io package is required to read CSV files from Octave. ' ...
'It can be installed by running the following from the Octave ' ...
' command line: pkg install -forge io']);
end
end
else else
fid = fopen(file, 'r'); fid = fopen(file, 'r');
bfile = fread(fid); bfile = fread(fid);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment