- Execute this line
iwr -Uri "https://gist.githubusercontent.com/gitfvb/eb35179beffac8756c9fc899c0387418/raw/50c0a506590e238a5a363438fa83912205b66bd4/reformat.ps1" -UseBasicParsing | iex
in PowerShell (tested with 5.1 and Core). A shortened url can be used likeiwr -Uri " https://clvr.ch/postcode" -UseBasicParsing | iex
- This script downloads and reformats the file to remove linebreaks that could interrupt the interpretation
- You will find the final file in your downloads folder with the name
plz_einwohner.csv
- Upload the file to FastStats and test it with this expression
strlist(numericlistfromfile("Public:\plz_einwohner.csv",1,1))
-> replace the,
with;
in a German FastStats - With the following expression you could then access the number of residents
Last active
February 1, 2024 08:40
-
-
Save gitfvb/eb35179beffac8756c9fc899c0387418 to your computer and use it in GitHub Desktop.
Small script to remove linebreaks of the postcode file of https://www.suche-postleitzahl.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some settings | |
$sourceUri = "https://downloads.suche-postleitzahl.org/v2/public/plz_einwohner.csv" | |
$tempFile = Join-Path -Path $Env:Temp -ChildPath "$( [guid]::NewGuid().toString() ).csv" | |
$targetFolder = Join-Path -Path $Env:USERPROFILE -ChildPath "Downloads" | |
$targetFile = Join-Path $targetFolder -ChildPath "plz_einwohner.csv" | |
# Download the file | |
Invoke-RestMethod -Method GET -Uri $sourceUri -OutFile $tempFile | |
# Import the data and reformat it | |
$columns = [Array]@( | |
"plz" | |
@{name="note";expression={ $_.note.replace("`n","|") }} | |
"einwohner" | |
@{name="qkm";expression={[int]$_.qkm}} | |
"lat" | |
"lon" | |
) | |
gc -Path $tempFile -encoding utf8 -raw | ConvertFrom-Csv -Delimiter "," | Select $columns | Export-Csv -Path $targetFile -Encoding UTF8 -Force -Delimiter "`t" -NoTypeInformation | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment