One PowerShell Jupyter Notebook, multiple experiments.
Simple experimentation with jupyter, PowerShell Invoke-ExcecuteNotebook
, and parameters.
You need the PowerShellNotebook
module installed for this to work. Install-Module -Name PowerShellNotebook
Parameterize the basic.ipynb notebook with $index
. It creates a new notebook with the $index
in the name and reads a csv
file based on the $index
.
basic.ipynb
$index = !$index ? "SNP" : $index
$csvFilename = "$($pwd.path)/exenb/datadir/{0}.csv" -f $index
$records = import-csv $csvFilename
"$index record count: $($records.count)"
runner.ps1
foreach ($index in 'SNP', 'GOLD', 'SSE', 'HANGSENG', 'NIKKEI') {
Invoke-ExecuteNotebook -Force `
-InputNotebook ./basic.ipynb `
-Parameters @{index = $index } `
-OutputNotebook ('basic_{0}.ipynb' -f $index)
}
result
Creates these notebooks with results from the execution.
- basic_GOLD.ipynb
- basic_HANGSENG.ipynb
- basic_NIKKEI.ipynb
- basic_SNP.ipynb
- basic_SSE.ipynb
The readExcel.ipynb
notebook takes a required parameter an xlfile
and two optional parameters sheetName
and itemName
.
sheetName
defaults to the sheet name one
in the notebook.
For example.
$params = @{
xlfile = (Resolve-Path ".\datadir\excelData.xlsx").Path
itemName = 'hammer'
}
Invoke-ExecuteNotebook -InputNotebook .\readExcel.ipynb -Parameters $params
Region Item TotalSold
------ ---- ---------
East hammer 51
South hammer 18