PowerShell でDataRobot Data データをCSV に落としてみた

標準PowerShell cmdlets を使ってDataRobot テーブルにアクセス。

CData Cmdlets Module for DataRobot は、直感的なDataRobot データ連携を提供する標準cmdlet です。 本記事では、DataRobot Cmdlets を使ったサンプルを提供します。

Creating a Connection to Your DataRobot Data

To connect to DataRobot, the following connection properties are required: User, Password, and PredictionInstance. DataRobotKey may also be required depending on your type of DataRobot predictions instance. If using the Predictions API, DataFile is required. The CSV DataFile should include a header row as the first row of the datafile. APIKey is not required, but can be supplied. If not supplied, the driver will handle obtaining an APIKey.

User, DataRobotKey, and APIKey are the credentials for the DataRobot account.

ProjectID, DataFile, and ModelId are the parameters for the project, dataset, and model type.

$conn = Connect-DataRobot  -PredictionInstance "$PredictionInstance" -DataFile "$DataFile" -DataRobotKey "$DataRobotKey" -User "$User" -Password "$Password"

Selecting Data

Follow the steps below to retrieve data from the Predictions table and pipe the result into to a CSV file:

Select-DataRobot -Connection $conn -Table Predictions | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myPredictionsData.csv -NoTypeInformation

You will notice that we piped the results from Select-DataRobot into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.

The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.
 
 
ダウンロード