public
Created

Data Brewery - Aggregate a Remote CSV File

  • Download Gist
brewery_example-aggregate.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
"""
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()

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.