community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Replacing characters within an KML file automatically

Alteryx Certified Partner
I am trying to combine multiple KML (Google Earth) files into 1 file (either KML or something else)
 
I do this via the Directory tool and the Dynamic Input tool. 
 
This goes all very well until within the KML file the "&" symbol is being used. 

The error provided is "Error: Dynamic Input (10): File Error: XML parsing of KML file failed : not well-formed (invalid token) at line 4, column 40
 
The KML file contains:

<Document>
    <name>text & text</name>

Alteryx gives an error on the "&". If I replace it manually by "and" there is no problem.

However, to automate matters, how can I replace the "&" via a module?

Thanks for the help,

Hans

 

Alteryx Alumni (Retired)
Hi Hans,

If you import the file as plain text using the Input Tool, you are then able to use the Formula Tool to update the text within the KML file.  Even better, you can pull in all KML files using the Input Tool and a wildcard character, attaching the file name to each of the records, then output dynamically as well.

I created a write-up on the Knowledge Sharing site that has a bit more explanation as well as an example module to download, check it out!

How To: Update Values Within A Series Of Text Files

Chad

Bolide
Bolide

+1 to Chad's answer.

This same methodology can be utilized to recover a csv with import errors caused by an extra delimiter. Normally, if you select the "treat errors as warnings" the csv will still process, however, the row with the extra delimiter will be blank. If you set the delimiter in the input tool to  "\0" then use the parse tool right after, its just a matter of cleaning to recover the once lost information.

I use this all the time when I receive dirty data from clients.

- Jarrod

 
Alteryx Certified Partner
Hi Chad, thanks for your help and the example, works very smoothly.

One remark for other people trying to do the same though: pls check the "Field Length" under the CSV input options. A KML polygon is easily more then the standard 254 characters. So by the default settings, it would get truncated.

Thanks all for the help!

Hans
ACE Emeritus
ACE Emeritus
+1 to Jarrod's comment

I've also used this trick when there are too many delimiters but instead of parsing, I use the "Regex_CountMatches" formula function to count all the delimiters in each row, a Summarize tool to see how many different values I have, and then a Filter to pull out the records where there are too many (or too few) delimiters. Now I can fix the problems if they're obvious or go back to the data supplier if they're not -- but with specific problems, not "your data file is dirty"!
Asteroid

Hey Chad, do you have an updated link to that article? I'm looking to edit a .kml output. My proof of concept is to add a dynamic <color></color> attribute.

 

Thanks,

Todd

Labels