Tis a silly thing. Converting KMZ to CSV.

We have a lot of KMZ files and it made me wonder if there was a way to display all those KMZ files in Power BI.

I was wondering if there was a bulk way to edit them all to CSV.

I’ve found some online tools but would be nifty to do it from PowerShell.

This is the KML file I got after unzipping it: https://pastebin.com/9U06gjX7

Should have updated my findings here and not in a comment below.

Update:

This is what I have now.

$scriptpath = "C:PSCodeProjectsKMZtoCSV" Add-Type -AssemblyName System.IO.Compression.FileSystem function unzip { param( [string]$ziparchive, [string]$extractpath ) [System.IO.Compression.ZipFile]::ExtractToDirectory( $ziparchive, $extractpath ) } #foreach ($kmzfile in $(get-childitem "$scriptpathKMZFiles" | select-object -expand FullName)){ $kmzfile = "C:PSCodeProjectsKMZtoCSVKMZFiles2348-Planned BH Locs.kmz" Remove-Item "$scriptpathExtractedKMZ" -Force -Recurse unzip $kmzfile "$scriptpathExtractedKMZ" [xml]$XML_In = Get-Content "$scriptpathExtractedKMZdoc.kml" $results = foreach ($line in $XML_In.kml.Document){ [pscustomobject]@{ FileName = $line.Name FolderName = $line.Folder.Name PlacemarkName = $line.Folder.Placemark.Name PlaceMarkCoordinates = $line.Folder.Placemark.Point.Coordinates } } $results | Export-Csv "$scriptpathexport.csv" -NoTypeInformation -Force #} 

Right now I am getting

"FileName","FolderName","PlacemarkName","PlaceMarkCoordinates" "Project.kmz","Project","System.Object[]","System.Object[]" 

so I need to figure out some way of expanding PlacemarkName and Placemark Coordinates. hmm

submitted by /u/sysadminworkaccount
[link] [comments]

Leave a Reply