[Tutor] cubes library docs are not accurate, first example failing unexpectedly
ThreeBlindQuarks
threesomequarks at proton.me
Thu Jun 8 19:14:01 EDT 2023
Marc,
I had noticed you posted more, including the tutorial, to the main python group. The tutorial does have typo's.
I am wondering if what you want to do might be done using other methods if this is not working as expected.
If the data is not too large and can be read in completely, some may place the columns wanted into a multi-dimensional construct that can also be accessed in various ways. The numpy and perhaps pandas modules can be useful or perhaps the more native matrix and array object types.
Your error messages seem to suggest something you are doing is returning nothing as in a list of whatever aggregates are. Have you checked if the data coming in is what was expected and perhaps if it is maintained in subsequent steps before the error?
I also note a search suggests OLAP Cubes are a bit outdated for some purposes.
So rather than just looking for a specific toolset, perhaps look at what you want to do with the data first and see what other tools provide the kind of functionality needed just for the job. If it become a whole production that needs to be fast and so on, then ...
Good luck.
Sent with Proton Mail secure email.
------- Original Message -------
On Thursday, June 8th, 2023 at 5:20 PM, ThreeBlindQuarks via Tutor <tutor at python.org> wrote:
> 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
>
> _______________________________________________
> 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