If you specify SelectedFormats, you must also specify SelectedVariableNames

Post Reply
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

If you specify SelectedFormats, you must also specify SelectedVariableNames

Post by matlab1 »

If you specify SelectedFormats, you must also specify SelectedVariableNames
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

Re: If you specify SelectedFormats, you must also specify SelectedVariableNames

Post by matlab1 »

Solution:

spreadsheetDatastore
Datastore for spreadsheet filesexpand

Description
Use a SpreadsheetDatastore object to manage large collections of spreadsheet files where the collection does not necessarily fit in memory. You can create a SpreadsheetDatastore object using the spreadsheetDatastore function, specify its properties, and then import the data using object functions.



Properties for preview, read, readall Table


SelectedVariableNames — Variables to read
character vector | cell array of character vectors | string scalar | string array
Variables to read from the file, specified as a character vector, cell array of character vectors, string scalar, or string array. Each character vector or string contains the name of one variable. You can specify the variable names in any order. You can specify SelectedVariableNames with a character vector or string scalar, however spreadsheetDatastore automatically converts it to a cell array of character vectors or a string array.

To support invalid MATLAB identifiers as variable names, such as variable names containing spaces and non-ASCII characters, set the value of VariableNamingRule parameter to 'preserve'.

Example: {'Var3','Var7','Var4'}

Data Types: char | cell | string

SelectedVariableTypes — Selected variable types
'double' | 'char' | 'string' | 'categorical' | 'datetime'
Selected variable types, specified as 'double', 'char', 'string', 'categorical', or 'datetime', which indicates the type of each selected variable when reading the data. The list of variable types corresponds with the variables in SelectedVariableNames. Types double, char, and datetime can be automatically detected from the data. You can specify SelectedVariableTypes as a character vector or string scalar, however it is automatically converted to a cell array of character vectors or string array.

Example: {'double','datetime'}

Data Types: char | cell | string

For more information,
https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.spreadsheetdatastore.html
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests