Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
5011_Big_Data/readtable.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
30 lines (22 sloc)
1.08 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function outtable = readtable(filepath) | |
% created 13/02/2021 by Keirnan Fowler, University of Melbourne | |
% This is a *very basic* Octave readtable function to replicate readtable in Matlab. | |
% It is only intended to work with the data input files of the stochastic generation | |
% framework example and may not be extendable to other contexts. | |
% suppress various pesky Octave warning messages (ensure you check | |
% correct import though!) | |
warning('off','all'); | |
% read the numerical data and column headers from the csv | |
ThisData = importdata(filepath, ',', 1); | |
% create separate vectors for each column | |
NumCols = size(ThisData.colheaders, 2); namestring = []; | |
for iCol = 1:NumCols | |
ColName = ThisData.colheaders{iCol}; | |
eval([ColName ' = ThisData.data(:, iCol);']); | |
namestring = [namestring ColName ', ']; | |
end | |
% create table from variables | |
eval(['outtable = table(' namestring(1:(end-2)) ');']); | |
% turn warnings back on | |
warning('default','all'); | |
end |