Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Convert CSV to Json with powershell
param
(
[string] $inputFile,
[string] $outputFile
)
if (($inputFile -eq $null) -or ($outputFile -eq $null)) {
"usage: convert_csv_to_json.ps1 [inputFile] [outputFile]"
return;
}
elseif ((Test-Path $inputFile) -eq $false) {
"The file $inputFile doesnt exists!"
return;
}
Get-Content -path $inputFile | ConvertFrom-Csv -Delimiter ';' | ConvertTo-Json | Out-File $outputFile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment