S = csv2struct(fname)         %Matlab & Octave when file is in the search path
S = csv2struct(dirpath,fname) %Matlab & Octave specify where the file is
#R to do

Read a CSV metadata file and convert it into a metadata structure. A metadata file is a text file containing a line for each metadata entry. The first comma-separated field in each line is the name of the entry which is a dot-separated list of structure elements, e.g., 'animal.dbase.url'. The last field in each line contains the value to be assigned to this metadata entry. The value can be a string or number but is always saved as a string in the structure - it is up to downstream users of the metadata to parse/decode the entries.

Input var Description Default
dirpath is a string containing the path to the file. If the file is on the search path, skip this argument.N/A
fname is the name of the metadata file. If the name does not include a .csv suffix, this will be added automatically.N/A
Output var Description Units
s is a metadata structure populated from the file N/A

Download test_set2.csv (2KB) to your working directory and type:

Matlab & Octave

 S = csv2struct('testset2') % returns: S with fields including S.depid='hs16_265c'.


# to do # returns: S with fields including S.depid='hs16_265c'.

bugs@animaltags.org Last modified: 12 July 2017

  • tagwiki/tools/io/csv2struct.txt
  • Last modified: 2017/08/05 11:22
  • by funkyfinwhale