Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheCloudScout/fad1becb6448b6502250a2e7654b7259 to your computer and use it in GitHub Desktop.
Save TheCloudScout/fad1becb6448b6502250a2e7654b7259 to your computer and use it in GitHub Desktop.
let unparsedData = datatable( string_:string )
[
"Country: United States City: Chicago Local dish: Deep dish pizza",
"City: New York City Attraction: Statue of Liberty Local dish: Cheesecake",
"Country: United States State: NV Population: 641903 Attraction: Fremont Street",
"State: CA City:San Francisco Population: 873965 Attraction: Golden Gate Bridge Local dish: Clam Chowder"
];
let parser1 = unparsedData
| where string_ has_all("Country:", "City:", "dish:")
| parse-where string_ with *
"Country: " country:string
"City: " city:string
"Local dish: " localDish:string
| project-away string_;
let parser2 = unparsedData
| where string_ has_all("City: ", "Attraction:", "dish:")
| parse-where string_ with *
"City: " city:string
"Attraction: " attraction:string
"Local dish: " localDish:string
| project-away string_;
let parser3 = unparsedData
| where string_ has_all("Country:", "State:", "Population:", "Attraction:")
| parse-where string_ with *
"Country: " country:string
"State: " state:string
"Population: " population:int
"Attraction: " attraction:string
| project-away string_;
let parser4 = unparsedData
| where string_ has_all("State:", "City:", "Population:", "Attraction:", "dish:")
| parse-where string_ with *
"State: " state:string
"City:" city:string
"Population: " population:int
"Attraction: " attraction:string
"Local dish: " localDish:string
| project-away string_;
union
parser1,
parser2,
parser3,
parser4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment