getvaropts
変数インポート オプションの取得
説明
例
関数 getvaropts
を使用して、変数のインポートを制御する変数インポート オプション オブジェクトにアクセスします。
ファイルからインポート オプションを作成します。オプション オブジェクトは、個々の変数のインポート オプションの集合です。
opts = detectImportOptions('patients.xls')
opts = SpreadsheetImportOptions with properties: Sheet Properties: Sheet: '' Replacement Properties: MissingRule: 'fill' ImportErrorRule: 'fill' MergedCellColumnRule: 'placeleft' MergedCellRowRule: 'placetop' Variable Import Properties: Set types by name using setvartype VariableNames: {'LastName', 'Gender', 'Age' ... and 7 more} VariableTypes: {'char', 'char', 'double' ... and 7 more} SelectedVariableNames: {'LastName', 'Gender', 'Age' ... and 7 more} VariableOptions: Show all 10 VariableOptions Access VariableOptions sub-properties using setvaropts/getvaropts VariableNamingRule: 'modify' Range Properties: DataRange: 'A2' (Start Cell) VariableNamesRange: 'A1' RowNamesRange: '' VariableUnitsRange: '' VariableDescriptionsRange: '' To display a preview of the table, use preview
指定した変数の変数インポート オプション オブジェクトを取得します。
varOpts = getvaropts(opts, 'Systolic')
varOpts = NumericVariableImportOptions with properties: Variable Properties: Name: 'Systolic' Type: 'double' FillValue: NaN TreatAsMissing: {} QuoteRule: 'remove' Prefixes: {} Suffixes: {} EmptyFieldRule: 'missing' Numeric Options: ExponentCharacter: 'eEdD' DecimalSeparator: '.' ThousandsSeparator: '' TrimNonNumeric: 0 NumberSystem: 'decimal'
変数のインポート オプションを変更するには、関数 setvaropts
と setvartype
のリファレンス ページを参照してください。
入力引数
ファイル インポート オプション。関数 detectImportOptions
によって作成された SpreadsheetImportOptions
オブジェクト、DelimitedTextImportOptions
オブジェクト、または FixedWidthImportOptions
オブジェクトとして指定します。opts
オブジェクトには、変数プロパティ、データの位置プロパティ、置換ルールなど、データのインポート プロセスを制御するプロパティが含まれます。
選択した変数。文字ベクトル、string スカラー、文字ベクトルの cell 配列、string 配列、数値インデックスの配列、または logical 配列として指定します。
変数名 (またはインデックス) は、opts
オブジェクトの VariableNames
プロパティに含まれる名前のサブセットでなければなりません。
例: 'Height'
例: {'Height','LastName'}
例: [5 9]
データ型: char
| string
| cell
| uint64
出力引数
選択した変数の型依存オプション。変数インポート オプション オブジェクトの配列として返します。配列には、selection
引数で指定された各変数に対応するオブジェクトが含まれます。変数のデータ型により、配列の各オブジェクトは数値、テキスト、logical
、datetime
および categorical
のいずれかの型になります。
それぞれのオブジェクトのプロパティは変更することができます。
Type
プロパティを変更するには、関数setvartype
を使用。他のプロパティを変更するには、関数
setvaropts
を使用。
バージョン履歴
R2016b で導入
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)