[Tutor] cubes library docs are not accurate, first example failing unexpectedly

ThreeBlindQuarks threesomequarks at proton.me
Thu Jun 8 17:20:22 EDT 2023


As a personal observation, Marc, your code contains lots of stuff above basic Python with use of various library functions. It becomes harder to know what exactly you want.

Could you explain what you mean by a "cube" for example? 

This line does not make it clear except that the module you are using lets you make a "cube" from whatever the workspace is you created earlier.

 cube = workspace.cube("irbd_balance")

So at the very least, please include what you expected as compared to what you got and some hint of what the data being received looked like. Did you get error messages or just the wrong output, or perhaps a problem downstream with the remaining code you show.

Of course, someone else here with experience in what you are using and doing may be able to answer. I can only ask for more info before making any suggestion.

Q 



Sent with Proton Mail secure email.

------- Original Message -------
On Thursday, June 8th, 2023 at 3:46 PM, marc nicole <mk1853387 at gmail.com> wrote:


> Hello to All,
> 
> I want to create a cube from csv data file and to perform and aggregation
> on it, the code is below:
> 
> from sqlalchemy import create_enginefrom cubes.tutorial.sql import
> create_table_from_csvfrom cubes import Workspace, Cell, browser
> import dataif name == 'main':
> engine = create_engine('sqlite:///data.sqlite')
> create_table_from_csv(engine,
> "../data/data.csv",
> table_name="irbd_balance",
> fields=[
> ("category", "string"),
> ("category_label", "string"),
> ("subcategory", "string"),
> ("subcategory_label", "string"),
> ("line_item", "string"),
> ("year", "integer"),
> ("amount", "integer")],
> create_id=True
> )
> print("done. file data.sqlite created")
> workspace = Workspace()
> workspace.register_default_store("sql", url="sqlite:///data.sqlite")
> workspace.import_model("../model.json")
> 
> 
> cube = workspace.cube("irbd_balance")
> 
> browser = workspace.browser("irbd_balance")
> 
> cell = Cell(cube)
> result = browser.aggregate(cell, drilldown=["year"])
> for record in result.drilldown:
> print(record)
> 
> 
> 
> 
> 
> The tutorial and the library are available here:
> 
> https://pythonhosted.org/cubes/tutorial.html
> The error stack is :
> 
> 
> result = browser.aggregate(cell, drilldown=["year"])
> File "C:\Users\path\venv\lib\site-packages\cubes\browser.py", line
> 145, in aggregate
> result = self.provide_aggregate(cell,
> File "C:\path\venv\lib\site-packages\cubes\sql\browser.py", line
> 400, in provide_aggregate
> (statement, labels) = self.aggregation_statement(cell,
> File "C:\path\venv\lib\site-packages\cubes\sql\browser.py", line
> 532, in aggregation_statement
> raise ArgumentError("List of aggregates should not be empty")
> cubes.errors.ArgumentError: List of aggregates should not be empty
> 
> It seems the tutorial is containing some typos.
> 
> Any idea how to fix this? Else is there any other better olap cubes
> library for Python that has great docs?
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list