From f3f2da54ff593da080522ba3a9dcc2d40312a8c4 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Fri, 21 Nov 2014 16:15:12 +0100
Subject: [PATCH] load_csv_file: try loading io package before error and expand
 error message

---
 matlab/load_csv_file_data.m | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/matlab/load_csv_file_data.m b/matlab/load_csv_file_data.m
index 72e5857c66..639ed5b30a 100644
--- a/matlab/load_csv_file_data.m
+++ b/matlab/load_csv_file_data.m
@@ -42,7 +42,13 @@ assert(exist(file, 'file') == 2, ['load_csv_file_data: I can''t find file ' file
 
 if isoctave
     if ~user_has_octave_forge_package('io')
-        error('The io package is required to read CSV files from Octave')
+        try
+            pkg load io
+        catch
+            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
     A = csv2cell(file);
     [data, T, L] = parsecell(A);
-- 
GitLab