-
Notifications
You must be signed in to change notification settings - Fork 2
/
ImportBody2.m
33 lines (28 loc) · 976 Bytes
/
ImportBody2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [name,value,head] = ImportBody2(filename,stringNo,Delimiter)
%ImportBody is a function to import a table from a csv file with header and measurement names
%The input file should be a complete .csv or other file
%If no Delimiter specified, we assume it is a csv.
%function [name,value,head] = ImportBody(filename,Delimiter,stringNo)
%Delimiter can be c(comma) or t(tab)
%Make sure you specify which column contains gene name using stringNo
%File example:
%Name ID HP
%Henry 506 238
%Diane 1322 124
%Sean 823 76
if nargin <2
stringNo = 1;
end;
if nargin < 3
Delimiter = 'c';
end;
if Delimiter=='t'
Table=readtable(filename,'Delimiter','\t');
else if Delimiter=='c'
Table=readtable(filename,'Delimiter',',');
end;
DataColumns=varfun(@isnumeric,Table(1,:),'output','uniform');
head=Table.Properties.VariableNames(DataColumns);
name=table2cell(Table(:,stringNo));
value=table2array(Table(:,DataColumns));
end;