-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfetchDataDJTable.m
More file actions
47 lines (40 loc) · 875 Bytes
/
fetchDataDJTable.m
File metadata and controls
47 lines (40 loc) · 875 Bytes
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function data = fetchDataDJTable(table, key, fields, type, extra_query, no_blobs)
if nargin < 2
key = [];
end
if nargin < 3
fields = {'*'};
end
if nargin < 4
type = "table";
end
if nargin < 5
extra_query = {};
end
if nargin < 6
no_blobs = false;
end
%Remove blob fields from fetch
if no_blobs
blob_fields = table.header.blobNames;
if fields{1} == '*'
fields = {table.header.attributes.name};
end
for i=1:length(blob_fields)
idx = find(ismember(fields, blob_fields{i}));
if ~isempty(idx)
fields(idx) = [];
end
end
end
if ~isempty(extra_query)
fields = [fields extra_query];
end
if isempty(key)
data = fetch(table, fields{:});
else
data = fetch(table & key, fields{:});
end
if ~isempty(data) && type == "table"
data = struct2table(data,'AsArray', true);
end