POR (.por)
予備知識
-
- MIMEタイプ:application/x-spss-por
- SPSSデータベース転送形式.
- レガシーデータ交換形式.
- 数値データセットをポータブル形式で保持する.
- バイナリ形式.
- SPSSは1968年にNorman H. Nie,Dale H. Bent,C. Hadlai Hullによってリリースされた.
- 1975年よりSPSS Inc.に,2009年からはIBM SPSS Statisticsによって保守されている.
ImportとExport
- Import["file.por"]はPORファイルをインポートし,すべてのデータ集合を表として並べて返す.
- PORデータはWolfram言語では,実数,整数,文字列,ブール値のTrueとFalse,およびDateObject指定によって表される.
- Import["file.por",elem]はPORファイルから指定の要素をインポートする.
- Import["file.por",{elem,suba,subb,…}] はサブ要素をインポートする,
- インポート形式はImport["file","POR"]またはImport["file",{"POR",elem,…}]で指定できる.
- Export["file.por",expr]は expr からPORファイルを生成する.
- サポートされる式 expr は以下の通り:
-
{v1,v2,…} 1列のデータ {{v11,v12,…},{v21,v22,…},…} データの行のリスト array SparseArray,QuantityArray等の配列 tseries TimeSeries,EventSeries,TemporalDataオブジェクト Dataset[…] データ集合 Tabular[…] 表形式オブジェクト <|"name1"expr1,…|> 名前付きの列の連想 - ImportとExportは以下のデータ型をサポートする:
-
"Date" 日付と時間の指定 "Integer8" 8ビット整数 "Integer16" 16ビット整数 "Integer32" 32ビット整数 "Real32" IEEEの単精度数 "Real64" IEEEの倍精度数 "String" 文字列 - 一般の完全な情報は以下のページを参照のこと:
-
Import, Export ファイルからインポートする,またはファイルへエキスポートする CloudImport, CloudExport クラウドオブジェクトからインポートする,またはクラウドオブジェクトへエキスポートする ImportString, ExportString 文字列からインポートする,または文字列へエキスポートする ImportByteArray, ExportByteArray バイト配列からインポートする,またはバイト配列へエキスポートする
要素
- 一般的なImport要素:
-
"Elements" ファイル中の有効な要素とオプションのリスト "Summary" ファイルの概要 "Rules" 使用可能なすべての要素の規則のリスト - データ表現要素:
-
"Data" 二次元配列 "Dataset" Datasetとして表された表データ "EventSeries" EventSeriesとしての表データ "LabeledData" ラベルとデータの連想 "LabeledRawData" ラベルと生データの連想 "Tabular" Tabularオブジェクトとして表された表データ "TimeSeries" TimeSeriesとしての表データ - Importはデフォルトで"Data"要素を使用する.
- データ記述子要素:
-
"ColumnDescriptions" 列の説明と型 "ColumnLabels" 列の名前 "ColumnTypes" 列の名前と型の連想 "MissingPositions" 欠損値とみなす要素のコラムごとの位置 "MissingValues" 欠損値とみなす列ごとの値 - メタデータ要素:
-
"ByteOrdering" データのエンディアン "CharacterEncoding" ファイルの文字コード "Comments" ファイルのコメント "Compression" ファイルで使用されている圧縮のタイプ "CreationDate" DateObjectで与えられる,ドキュメントの作成日 "Dimensions" データの次元 "MetaInformation" 文字列と日付オブジェクトとして与えらるメタデータ "ModificationDate" DateObjectで与えられる,ドキュメントの変更日 "TableName" 表全体の名前 "Version" ファイルのSAS仕様のバージョン
オプション
- Importオプション:
-
"ColumnDefaultValues" Automatic 列名とデフォルト値の連想 "TimeColumn" Automatic "EventSeries"要素および"TimeSeries"要素での時間に使用する列 "TypeDefaultValues" Automatic 型とデフォルト値の連想 - Exportオプション:
-
"ColumnDescriptions" Automatic それぞれの列を説明するリスト "MetaInformation" Automatic メタデータのタグと値の連想 - "ColumnDescriptions" の設定は以下のものが可能である:
-
{"label1","label2", …} 列の名前を与える文字列のリスト {assoc,…} 列のメタデータを与える連想のリスト <|colassoc|> インデックスまたは列の名前と列のメタデータの連想 - assoc で可能なキーは以下の通り:
-
"Name" 列の名前を与える文字列 "Description" 列の説明を与える文字列 "Type" 列の型を与える文字列 "MissingValues" 列に欠落していると思われる値 - "MetaInformation"で可能なキーは以下の通り:
-
"Comments" ファイル上で一般的なコメントを与える文字列 "CreationDate" ファイルの作成日を与える日付オブジェクト "ModificationDate" ファイルの変更日を与える日付オブジェクト "TableName" 完全な表の名前を与える文字列 "Version" ファイルのバージョンを与える整数
例題
すべて開く すべて閉じる例 (3)
Import["ExampleData/sample.por"]Import["ExampleData/sample.por", "Summary"]file = Export["test.por", {{"String1", DateObject[{2000, 1, 1}, "Day"], Missing["NotAvailable"], 8.25}, {"String2", DateObject[{2000, 1, 2}, "Day"], 0.41, 1.44}, {"String3", DateObject[{2000, 1, 3}, "Day"], Missing["NotAvailable"], Missing["NotAvailable"]}}]Import[file, "Tabular"]スコープ (8)
Import (3)
Import["ExampleData/sample.por", "Elements"]Import["ExampleData/sample.por", "Data"]Tabularオブジェクトとしてインポートする:
Import["ExampleData/sample.por", "Tabular"]Export (5)
Datasetをエキスポートする:
dataset = Dataset[{
<|"A" -> 1, "B" -> DateObject[{2000, 1, 1}, "Day"]|>,
<|"A" -> 2, "B" -> DateObject[{2000, 1, 2}, "Day"]|>,
<|"A" -> 3, "B" -> DateObject[{2000, 1, 3}, "Day"]|>}]file = Export["test.por", dataset];Import[file, "Dataset"]file = Export["test.por", {{1, 2, 3}, {4, 5, 6}}]Import[file, "Dataset"]file = Export["test.por", <|"A" -> {1, 2, 3}, "B" -> {4, 5, 6}|>]Import[file, "Dataset"]TimeSeriesをエキスポートする:
t = {1, 2, 5, 10, 12, 15};
v = {2, 1, 6, 5, 7, 4};ts = TimeSeries[v, {t}]file = Export["test.por", ts]Import[file, "Dataset"]不完全な配列は自動的に右に空欄が充填され,完全配列に変換される:
file = Export["test.por", {a, {d, e, f}}]Import[file, "Dataset"]Import要素 (18)
データ表現 (7)
"Data" (1)
"Dataset" (1)
"EventSeries" (1)
TabularオブジェクトをPORファイルにエキスポートする:
file = Export["test.por", Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["DATE" -> Association["ElementType" -> TypeSpecifier["Date"]["Integer32", "Day",
"Gregorian", 0]], "VALUE" -> Association["ElementType" -> "Real32"]],
"KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {},
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {5, {{NumericArray[{13150, 13151, 13152, 13153, 13156},
"Integer32"], {}, None}}, None}, "ElementType" -> "Date"["Integer32", "Day",
"Gregorian", 0]]], TabularColumn[Association["Data" ->
{NumericArray[{11.819999694824219, 12.039999961853027, 12.09000015258789,
11.880000114440918, 12.430000305175781}, "Real32"], {}, None},
"ElementType" -> "Real32"]]}}]]]]];EventSeriesとしてPORファイルをインポートする:
Import[file, "EventSeries"]"LabeledData" (1)
"LabeledRawData" (1)
"Tabular" (1)
"TimeSeries" (1)
TabularオブジェクトをPORファイルにエキスポートする:
file = Export["test.por", Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["DATE" -> Association["ElementType" -> TypeSpecifier["Date"]["Integer32", "Day",
"Gregorian", 0]], "VALUE" -> Association["ElementType" -> "Real32"]],
"KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {},
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {5, {{NumericArray[{13150, 13151, 13152, 13153, 13156},
"Integer32"], {}, None}}, None}, "ElementType" -> "Date"["Integer32", "Day",
"Gregorian", 0]]], TabularColumn[Association["Data" ->
{NumericArray[{11.819999694824219, 12.039999961853027, 12.09000015258789,
11.880000114440918, 12.430000305175781}, "Real32"], {}, None},
"ElementType" -> "Real32"]]}}]]]]];TimeSeriesとしてPORファイルをインポートする:
Import[file, "TimeSeries"]データ記述子 (5)
"ColumnDescriptions" (1)
"ColumnLabels" (1)
"ColumnTypes" (1)
"MissingPositions" (1)
メタデータ (6)
"Comments" (1)
"CreationDate" (1)
"Dimensions" (1)
"MetaInformation" (1)
"ModificationDate" (1)
Importオプション (3)
"ColumnDefaultValues" (1)
Normal[Lookup[Import["ExampleData/sample.por", "LabeledRawData"], {"MISSING", "RANGE"}]]//Function[...]"ColumnDefaultValues"を使って特定の列に別のデフォルト値を指定する:
Normal[Lookup[Import["ExampleData/sample.por", "LabeledRawData", "ColumnDefaultValues" -> <|"MISSING" -> -1., "RANGE" -> -10.|>], {"MISSING", "RANGE"}]]//Function[...]"TimeColumn" (1)
TabularオブジェクトをPORファイルにエキスポートする:
file = Export["test.por", Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["DATE" -> Association["ElementType" -> TypeSpecifier["Date"]["Integer32", "Day",
"Gregorian", 0]], "VALUE" -> Association["ElementType" -> "Real32"]],
"KeyColumns" -> None, "Backend" -> "WolframKernel"], "Options" -> {},
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {5, {{NumericArray[{13150, 13151, 13152, 13153, 13156},
"Integer32"], {}, None}}, None}, "ElementType" -> "Date"["Integer32", "Day",
"Gregorian", 0]]], TabularColumn[Association["Data" ->
{NumericArray[{11.819999694824219, 12.039999961853027, 12.09000015258789,
11.880000114440918, 12.430000305175781}, "Real32"], {}, None},
"ElementType" -> "Real32"]]}}]]]]];デフォルトでは,"TimeSeries"要素および"EventSeries"要素の時間列が自動的に選択される:
Import[file, "TimeSeries"]"TimeColumn"オプションを使って時間列を指定する:
Import[file, "TimeSeries", "TimeColumn" -> "VALUE"]"TypeDefaultValues" (1)
Normal[Lookup[Import["ExampleData/sample.por", "LabeledData"], {"MISSING", "RANGE"}]]//Function[...]"TypeDefaultValues"を使って特定の型に別のデフォルト値を指定する:
Normal[Lookup[Import["ExampleData/sample.por", "LabeledData", "TypeDefaultValues" -> <|"Real64" -> -1.|>], {"MISSING", "RANGE"}]]//Function[...]Exportオプション (2)
"ColumnDescriptions" (1)
Export["test.por", {{1, 2., "3"}, {4, 5., "6"}}]Import["test.por", "ColumnDescriptions"]"ColumnDescriptions"を使って,列の型や概要を特定できる:
Export["test.por", {{1, 2., "3"}, {4, 5., "6"}}, "ColumnDescriptions" -> {<|"Type" -> "String", "Description" -> "String data."|>, <|"MissingValues" -> {2}|>}]Import["test.por", "ColumnDescriptions"]Import["test.por"]"MetaInformation" (1)
関連するガイド
-
▪
- インポートとエキスポート ▪
- 全形式のリスト ▪
- 数値データ形式 ▪
- 統計的データ解析 ▪
- 表とスプレッドシート形式 ▪
- 時系列と事象系列の形式