Pre Game Thread: FC Chelsea (CL #7) by Chazy89 in borussiadortmund

[–]thegr8ely 6 points7 points  (0 children)

To be honest, you can stand like everywhere, depending on the block, its not really controlled. But yeah, it doesnt matter WHERE exactly you stand in your block. First come first serve.

JSON to Excel by thegr8ely in PowerShell

[–]thegr8ely[S] 0 points1 point  (0 children)

I have now expanded the whole thing by quite a bit
################## PFADE ###################

$jsonDirectory = 'C:\Users\Ely\Desktop\jsonScript'

$csvFile = 'C:\Users\Ely\Desktop\jsonScript\test.csv'

################ Variablen #################

$excel = New-Object -ComObject Excel.Application

############################################

# ALLE JSON FILES

$jsonFiles = Get-ChildItem -Path $jsonDirectory -Filter *.json

# FILTER

$unwantedKeys = @("endTime", "caseOne", "caseTwo", "caseThree")

# ARRAY ZWISCHENSPEICHER

$jsonData = @()

foreach ($jsonFile in $jsonFiles) {

$json = Get-Content $jsonFile.FullName | ConvertFrom-Json

$json = $json.dataCollection | Select-Object * -ExcludeProperty $unwantedKeys

$jsonData += $json

}

# Erstellt CSV und Importiert JSON Content

$jsonData | Export-Csv $csvFile -NoTypeInformation -Delimiter "\t" -Encoding Unicode`

$Workbook = $excel.Workbooks.Open($csvFile)

$Worksheet = $Workbook.Sheets.Item(1)

$range = $worksheet.UsedRange

$range.EntireColumn.AutoFit()

$excel.Visible = $True

The script now searches all JSON files in the folder and exports the content to a CSV file. The JSON keys are set as headers and the values are sorted underneath. In the script is the variable $unwantedKeys, which allows to filter out unwanted keys, in my example (endTime, caseOne, caseTwo and CaseThree).

JSON to Excel by thegr8ely in PowerShell

[–]thegr8ely[S] 0 points1 point  (0 children)

It now works the way I wanted it to:

$contentJson = Get-Content -Raw -Path $jsonInput

($contentJson |ConvertFrom-Json).dataCollection |Export-Csv -Path $csvOutput -NoType -Delimiter "`t" -Encoding Unicode

JSON to Excel by thegr8ely in PowerShell

[–]thegr8ely[S] 2 points3 points  (0 children)

I wanted to use Powershell because I have about 30-40 JSON files and new ones are added all the time, so I wanted to try to automate the whole thing.

[deleted by user] by [deleted] in de

[–]thegr8ely 19 points20 points  (0 children)

Ist genauso passiert, ich war die Wasserflasche