Last active
August 29, 2015 14:04
-
-
Save mikedewar/af6ec57d35dd1c6a33e7 to your computer and use it in GitHub Desktop.
streamtools pattern to parse the FCC "Comments on Protecting and Promoting the Open Internet" XML files.
This file contains 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
{ | |
"Connections": [ | |
{ | |
"ToRoute": "in", | |
"ToId": "1", | |
"FromId": "4", | |
"Id": "5" | |
}, | |
{ | |
"ToRoute": "in", | |
"ToId": "6", | |
"FromId": "1", | |
"Id": "7" | |
}, | |
{ | |
"ToRoute": "in", | |
"ToId": "11", | |
"FromId": "9", | |
"Id": "18" | |
}, | |
{ | |
"ToRoute": "pop", | |
"ToId": "9", | |
"FromId": "10", | |
"Id": "16" | |
}, | |
{ | |
"ToRoute": "in", | |
"ToId": "2", | |
"FromId": "6", | |
"Id": "8" | |
}, | |
{ | |
"ToRoute": "in", | |
"ToId": "3", | |
"FromId": "6", | |
"Id": "13" | |
}, | |
{ | |
"ToRoute": "in", | |
"ToId": "12", | |
"FromId": "11", | |
"Id": "15" | |
}, | |
{ | |
"ToRoute": "push", | |
"ToId": "9", | |
"FromId": "3", | |
"Id": "17" | |
} | |
], | |
"Blocks": [ | |
{ | |
"Position": { | |
"Y": 512.991455078125, | |
"X": 409.991455078125 | |
}, | |
"Rule": { | |
"Filename": "doc.json" | |
}, | |
"Type": "tofile", | |
"Id": "2" | |
}, | |
{ | |
"Position": { | |
"Y": 335, | |
"X": 512.9971466064453 | |
}, | |
"Rule": { | |
"Path": ".body" | |
}, | |
"Type": "parsexml", | |
"Id": "6" | |
}, | |
{ | |
"Position": { | |
"Y": 665.991455078125, | |
"X": 829 | |
}, | |
"Rule": { | |
"Map": { | |
"zip": ".arr[17].str", | |
"state": ".arr[13].str", | |
"date": ".arr[4].date", | |
"comment": ".arr[15].str", | |
"city": ".arr[3].str", | |
"applicant": ".arr[0].str" | |
}, | |
"Additive": false | |
}, | |
"Type": "map", | |
"Id": "11" | |
}, | |
{ | |
"Position": { | |
"Y": 222.9943084716797, | |
"X": 408.991455078125 | |
}, | |
"Rule": { | |
"UrlPath": "", | |
"Url": "http://www.fcc.gov/files/ecfs/14-28/14-28-RAW-Solr-1.xml", | |
"Method": "GET", | |
"Headers": {}, | |
"BodyPath": "." | |
}, | |
"Type": "webRequest", | |
"Id": "1" | |
}, | |
{ | |
"Position": { | |
"Y": 750.9885864257812, | |
"X": 927.9971313476562 | |
}, | |
"Rule": { | |
"Filename": "comments.json" | |
}, | |
"Type": "tofile", | |
"Id": "12" | |
}, | |
{ | |
"Position": { | |
"Y": 582.991455078125, | |
"X": 725.9971313476562 | |
}, | |
"Rule": null, | |
"Type": "queue", | |
"Id": "9" | |
}, | |
{ | |
"Position": { | |
"Y": 108, | |
"X": 370.99713134765625 | |
}, | |
"Rule": null, | |
"Type": "bang", | |
"Id": "4" | |
}, | |
{ | |
"Position": { | |
"Y": 417.99713134765625, | |
"X": 601.9971313476562 | |
}, | |
"Rule": { | |
"Path": ".response.result.doc" | |
}, | |
"Type": "unpack", | |
"Id": "3" | |
}, | |
{ | |
"Position": { | |
"Y": 493, | |
"X": 536.9942626953125 | |
}, | |
"Rule": { | |
"Interval": "500us" | |
}, | |
"Type": "ticker", | |
"Id": "10" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this, run streamtools (find out more at http://nytlabs.github.io/streamtools/). To import this package download it to your computer and run
This will create a pattern in your running streamtools. Then, in a browser, visit http://localhost:7070 and you should see a bunch of connected blocks. In the top left of the pattern is the
bang
block. If you click on the red square on thebang
block it will set the whole thing going.Beware! It takes a few seconds to download the file, and then a few more seconds to parse the XML, and then a few more seconds to write the nice json to a file. At the end of that (be patient!) you should have a file called
comments.json
in the directory you ran streamtools from.Each line of that file is a single comment, that looks like:
(I have edited some fields to spare the innocent).