Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jsbsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SASC
jsbsim
Commits
ccb6cb2d
Commit
ccb6cb2d
authored
13 years ago
by
James Goppert
Browse files
Options
Downloads
Patches
Plain Diff
Added read_csv.sci from master.
parent
4cbb76ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
read_csv.sci
+63
-0
63 additions, 0 deletions
read_csv.sci
with
63 additions
and
0 deletions
read_csv.sci
0 → 100644
+
63
−
0
View file @
ccb6cb2d
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2008 - INRIA
// Copyright (C) 2009 - DIGITEO - Allan CORNET
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
function stat = isfile(fname)
stat = (fileinfo(fname) ~= [])
endfunction
function strOut = gettext(str)
strOut = str
endfunction
function mat = read_csv(fname,sep)
// Given an ascii file created by Excel using "Text and comma" format
// read_csv(fname) returns the corresponding Scilab matrix of strings.
if (type(fname) <> 10) then
error(msprintf(gettext("%s: Wrong type for input argument #%d: a string expected.\n"), 'write_csv', 1));
end
if (size(fname,'*')<> 1) then
error(msprintf(gettext("%s: Wrong size for input argument #%d: a string expected.\n"), 'write_csv', 1));
end
if argn(2)<2 then
sep = ',';
end
if ~isfile(fname) then
//error(msprintf(gettext("%s: file %s does not exist.\n"), 'write_csv', 1, fname));
error('file doesn''t exist')
end
v = mgetl(fname);
ns = length(sep);
mat = [];
ki = 1;
for i = 1 : size(v,'*')
line = v(i);
K = [strindex(line, sep)];
ki = 1;
row = [];
for k = K
row = [row, part(line,ki:k-1)];
ki = k + ns;
end
row = [row, part(line, ki:length(line))];
if (i > 1) then
if size(row,2) > size(mat,2) then
mat($,size(row,2)) = '';
elseif size(row,2) < size(mat,2) then
row(size(mat,2)) = '';
end
end
mat = [mat; row];
end
endfunction
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment