Created
April 3, 2012 20:32
-
-
Save Stiivi/2295299 to your computer and use it in GitHub Desktop.
Data Brewery - Aggregate a Remote CSV File
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
""" | |
Data Brewery Example | |
Aggregate a remote CSV file. | |
""" | |
import brewery | |
main = brewery.create_builder() | |
main.csv_source("https://raw.github.com/Stiivi/cubes/master/examples/hello_world/data.csv") | |
main.node.fields = brewery.FieldList([ | |
"category_code", | |
"category", | |
"subcategory_code", | |
"subcategory", | |
"line_item", | |
"year", | |
["amount", "float"] | |
]) | |
main.aggregate(keys=["year", "category"], measures=["amount"]) | |
main.field_map(keep_fields=["year", "category", "amount_sum"]) | |
main.pretty_printer() | |
main.stream.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment