The parse function reads the file and puts it into an XMLĭata structure. I print the header to the file and the screen. "fout" is the output file handle to the CSV file. Out the layers I'm not working with at the moment. Rather than parameterize it, I just comment I wanted to work with one KML file at a time. The coordinates for the polygon are several layers ofįind functions on the Placemark node, I just define the find string once. You can specify your namespaces as an array One thing I struggled with is that the Namespaceįor your XML schema needs to be specified in most of the calls to API. The only module I imported is the ElementTree API. Print(Section,RingOrder,cols,cols,sep=',',file=fout) Print(Section,RingOrder,cols,cols,sep=',') Print ('Section,RingOrder,Long,Lat',file=fout)įor placemark in docelem.findall('Placemark',ns): Wherecoords = 'Polygon/outerBoundaryIs/LinearRing/coordinates'Ĭsvfile = kmlfile.split(sep='.') + '.csv' # Where is "coordinates" in each Placemark? I want a spreadsheet that contains all the coordinates, grouped by section and ordered by their sequence around the polygon.
The first and last points do not have to match. #"Pivoted Column" = Table.Pivot(#"Expanded Data", List.A triangle polygon has four points. #"Changed Type" = Table.TransformColumnTypes(Table0,), Source = Xml.Tables(File.Contents("c:\path\to\kml file.kml")), Or, just click on "Advanced editor", and replace the whole textbox content with this: let Expand the right-most header (Folder) until it can't be expanded anymore. In the right of the header, there's a little doohickey that lets you expand each table. This will load the document which will show up as just a couple of rows with "Table" in the cells. On Excel 2016, go to data tab and click this:, then choose your KML file. I have hundreds of thousands of lines of this sort of data.įOREWORD: if you're on a Mac, don't read what follows as it's not supported. Does anyone know of a way to have excel recognize this schema and create columns for the individual pieces of information that make up a data set? For example, I would like a name column, an address column, city column, etc.Ĭity: HooksettSt/Pr: NHZip: 3106Country: USAWebsite: Phone: (123) 458-6079Fax: DOT #: 123456MC #: 12345# Units: 7Description: this is an example]]> I have found a way to get the data saved as KML and have converted that to text, you will find below a sample of the data. I am attempting to export 46,000 data sets from a private Google map into an excel database. Recent ClippyPoint Milestones !Ĭongratulations and thank you to these contributors DateĪ community since MaDownload the official /r/Excel Add-in to convert Excel cells into a table that can be posted using reddit's markdown. Include a screenshot, use the tableit website, or use the ExcelToReddit converter (courtesy of u/tirlibibi17) to present your data.
#Upload kml to csv code
You can select code in your VBA window, press Tab, then copy and paste into your post or comment. To apply code formatting Use 4 spaces to start each line This will award the user a ClippyPoint and change the post's flair to solved. OPs can (and should) reply to any solutions with: Solution Verified
Only text posts are accepted you can have images in Text posts.