Textreadr: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
(Importing text file)
 
imported>Jeremy
(Importing text file)
Line 6: Line 6:
XCLREADR reads tab, space, comma, semicolon or bar delimited files with names on the columns (variables) and rows (samples).
XCLREADR reads tab, space, comma, semicolon or bar delimited files with names on the columns (variables) and rows (samples).
If XCLREADR is called with no input, or an empty matrix for file name ''file'', a dialog box allows the user to select a file to read from the hard disk.
If XCLREADR is called with no input, or an empty matrix for file name ''file'', a dialog box allows the user to select a file to read from the hard disk.
INPUTS:
====INPUTS====
file = One of the following identifications of files to read:
file = One of the following identifications of files to read:
* a)  a single string identifying the file to read  
* '''a)''' a single string identifying the file to read  
*  ('example.txt')
'''('example.txt')
* b)  a cell array of strings giving multiple files to read  
**''''''''''''''' b)  a cell array of strings giving multiple files to read  
*  ({'example_a' 'example_b' 'example_c'})
'''({'example_a'''' 'example_b' 'example_c'})
* c)  an empty array indicating that the user should be prompted to locate the file(s) to read  
* '''c)''' an empty array indicating that the user should be prompted to locate the file(s) to read  
*  ([])
'''([])
delim = An optional string used to specify the delimiter character.
delim''' = An optional string used to specify the delimiter character.
Supported delimiters include:
Supported delimiters include:
* 'tab'  or  '\t' or sprintf('\t')
* ''''tab''''  or  '\t' or sprintf('\t')
* 'space'  or  ' '
* ''''space''''  or  ' '
* 'comma'  or  ','
* ''''comma''''  or  ','
* 'semi'  or  ';'
* ''''semi''''  or  ';'
* 'bar'    or  '|'
* ''''bar''''    or  '|'
If (delim) is omitted, the file will be searched for a delimiter common to all rows of the file and producing an equal number of columns in the result.
If (delim) is omitted, the file will be searched for a delimiter common to all rows of the file and producing an equal number of columns in the result.
OUTPUTS:
====OUTPUTS====
out = A DataSet object with date, time, info (data from cell (1,1)) the variable names vars, sample names samps, and data matrix data.  Note that the primary difference between this function and the Mathworks function xlsread is the parsing of labels and output of a dataset object.
out = A DataSet object with date, time, info (data from cell (1,1)) the variable names vars, sample names samps, and data matrix data.  Note that the primary difference between this function and the Mathworks function xlsread is the parsing of labels and output of a dataset object.
Note that the primary difference between this function and the Mathworks function xlsread is the parsing of labels and output of a dataset object.
Note that the primary difference between this function and the Mathworks function xlsread is the parsing of labels and output of a dataset object.
===Options===
===Options===
* ''options'' = a structure array with the following fields:
* '''''options''''' = a structure array with the following fields:
* parsing: [ 'manual' | {'automatic'} | 'auto_strict' ] determines the type of parsing to perform:
* '''parsing''': [ 'manual' | {'automatic'} | 'auto_strict' ] determines the type of parsing to perform:
*  'automatic' : the file is automatically parsed for labels and header information. This works on many standard arrangements with different numbers of rows and column labels. May take some time to complete with larger files. See note below regarding additional options available with 'automatic' parsing.
''''automatic'''' : the file is automatically parsed for labels and header information. This works on many standard arrangements with different numbers of rows and column labels. May take some time to complete with larger files. See note below regarding additional options available with 'automatic' parsing.
*  'auto_strict' : faster automatic parsing which does not handle header lines, and expects that all row labels will be on the left-hand side of the data and all column labels will be on the top of the columns. If this returns the wrong result, try 'automatic'.
''''auto_strict'''' : faster automatic parsing which does not handle header lines, and expects that all row labels will be on the left-hand side of the data and all column labels will be on the top of the columns. If this returns the wrong result, try 'automatic'.
*  'manual' : the options below are used to determine the number of labels and header information.
''''manual'''' : the options below are used to determine the number of labels and header information.
*  Note that when the file type is XLS, 'automatic' parsing is always performed.  
'''Note''' that when the file type is XLS, 'automatic' parsing is always performed.  
*  (the following options are only used when options.parsing='manual')
'''(the''' following options are only used when options.parsing='manual')
*commentcharacter: [''] any line that starts with the given character will be considered a comment and parsed into the"comment" field of the DataSet object. Deafult is no comment character. Example: '%' uses % as a commentcharacter.
*'''commentcharacter''': [''] any line that starts with the given character will be considered a comment and parsed into the"comment" field of the DataSet object. Deafult is no comment character. Example: '%' uses % as a commentcharacter.
*  NOTE: Only used with 'automatic' and 'manual' parsing, NOT with 'auto_strict' parsing.
'''NOTE''': Only used with 'automatic' and 'manual' parsing, NOT with 'auto_strict' parsing.
* headerrows: [{0}] number of header rows to expect in the file.
* '''headerrows''': [{0}] number of header rows to expect in the file.
* rowlabels: [{1}] number of row labels to expect in the file.
* '''rowlabels''': [{1}] number of row labels to expect in the file.
* collabels: [{1}] number of column labels to expect in the file.
* '''collabels''': [{1}] number of column labels to expect in the file.
*The default options can be retreived using: options = xclreadr('options');
*'''The''' default options can be retreived using: options = xclreadr('options');
In addition to the above options, if option parsing is set to 'automatic', any option used by the PARSEMIXED function can be input to XCLREADR. These options will be passed directly to PARSEMIXED for use in parsing the file. See PARSEMIXED for details.
In addition to the above options, if option parsing is set to 'automatic', any option used by the PARSEMIXED function can be input to XCLREADR. These options will be passed directly to PARSEMIXED for use in parsing the file. See PARSEMIXED for details.
===See Also===
===See Also===
[[areadr]], [[dataset]], [[spcreadr]], [[xclgetdata]], [[xclputdata]], [[xlsreadr]]
[[areadr]], [[dataset]], [[spcreadr]], [[xclgetdata]], [[xclputdata]], [[xlsreadr]]

Revision as of 19:58, 2 September 2008

Purpose

Reads ASCII flat files from MS Excel and other spreadsheets as a DataSet Object.

Synopsis

out = xclreadr(file,delim,options)

Description

XCLREADR reads tab, space, comma, semicolon or bar delimited files with names on the columns (variables) and rows (samples). If XCLREADR is called with no input, or an empty matrix for file name file, a dialog box allows the user to select a file to read from the hard disk.

INPUTS

file = One of the following identifications of files to read:

  • a) a single string identifying the file to read
  • ('example.txt')
    • '''''''''' b) a cell array of strings giving multiple files to read
  • ({'example_a' 'example_b' 'example_c'})
  • c) an empty array indicating that the user should be prompted to locate the file(s) to read
  • ([])

delim = An optional string used to specify the delimiter character. Supported delimiters include:

  • 'tab' or '\t' or sprintf('\t')
  • 'space' or ' '
  • 'comma' or ','
  • 'semi' or ';'
  • 'bar' or '|'

If (delim) is omitted, the file will be searched for a delimiter common to all rows of the file and producing an equal number of columns in the result.

OUTPUTS

out = A DataSet object with date, time, info (data from cell (1,1)) the variable names vars, sample names samps, and data matrix data. Note that the primary difference between this function and the Mathworks function xlsread is the parsing of labels and output of a dataset object. Note that the primary difference between this function and the Mathworks function xlsread is the parsing of labels and output of a dataset object.

Options

  • options = a structure array with the following fields:
  • parsing: [ 'manual' | {'automatic'} | 'auto_strict' ] determines the type of parsing to perform:
  • 'automatic' : the file is automatically parsed for labels and header information. This works on many standard arrangements with different numbers of rows and column labels. May take some time to complete with larger files. See note below regarding additional options available with 'automatic' parsing.
  • 'auto_strict' : faster automatic parsing which does not handle header lines, and expects that all row labels will be on the left-hand side of the data and all column labels will be on the top of the columns. If this returns the wrong result, try 'automatic'.
  • 'manual' : the options below are used to determine the number of labels and header information.
  • Note that when the file type is XLS, 'automatic' parsing is always performed.
  • (the following options are only used when options.parsing='manual')
  • commentcharacter: [] any line that starts with the given character will be considered a comment and parsed into the"comment" field of the DataSet object. Deafult is no comment character. Example: '%' uses % as a commentcharacter.
  • NOTE: Only used with 'automatic' and 'manual' parsing, NOT with 'auto_strict' parsing.
  • headerrows: [{0}] number of header rows to expect in the file.
  • rowlabels: [{1}] number of row labels to expect in the file.
  • collabels: [{1}] number of column labels to expect in the file.
  • The default options can be retreived using: options = xclreadr('options');

In addition to the above options, if option parsing is set to 'automatic', any option used by the PARSEMIXED function can be input to XCLREADR. These options will be passed directly to PARSEMIXED for use in parsing the file. See PARSEMIXED for details.

See Also

areadr, dataset, spcreadr, xclgetdata, xclputdata, xlsreadr