read_cats_csv
Read a CSV file with sensor data from a CATS tag.
Syntax
[V,HDR,EMPTY] = read_cats_csv(fname) % Matlab & Octave % or [V,HDR,EMPTY] = read_cats_csv(fname,maxsamps) % Matlab & Octave
Description
Read a CSV file with sensor data from a CATS tag. CATS CSV files can be very large and a number of steps are taken here to maximize speed and avoid memory problems. This function is usable by itself but is more normally called by read_cats() which handles metadata and creates a NetCDF file.
Inputs
Input var | Description | Default value |
---|---|---|
fname | is the file name of the CATS CSV file including the complete path name if the file is not in the current working directory or in a directory on the path. The .csv suffix is not needed. | N/A |
maxsamps | is optional and is used to limit reading to a maximum number of samples per sensor. This is useful to read in a part of a very large file for testing. If maxsamps is not given, the entire file is read. | N/A |
Outputs
Output var | Description | Units |
---|---|---|
V | is a matrix of data read from the file. V has a line for each data line in the file. The number of columns is one less than the number of non-empty fields. This is because date and time which appear as separate fields in the CSV file are amalgamated into a date number in V(:,1). Empty fields, i.e., fields that do not contain a number, are removed. | N/A |
HDR | is a cell array of strings containing the names of non-empty fields. The field names are taken from the first line of the CSV file and include units and axis. HDR has the same number of cells as there are columns in V. | N/A |
EMPTY | is a cell array of strings containing the names of empty fields. | N/A |
Notes & assumptions
Warning: CATS loggers can produce very large csv files which are slow to prrocess. This function is optimised for speed and memory use so will tolerate large files. But processing could be slow.
Example
Download the cats_test_segment.csv to run this example.
Matlab & Octave
[V,HDR,EMPTY] = read_cats_csv('cats_test_segment',100) %Reads 100 samples from file cats_test_segment.csv and returns the data and field information. </code>
R
About
bugs@animaltags.org Last modified: 21 July 2017