Open Juan-hwt opened 3 months ago
Hello, try to clone the last repo version, I slightly changed the ADOMD library path detection. If it doesn't work let me know.
I changed like this and it works!
suggest you update pip
adomdPath = r"C:\Program Files\Microsoft.NET\ADOMD.NET\{}".format(next(os.walk(r'C:\Program Files\Microsoft.NET\ADOMD.NET'))[1][0])
df = pbi.getTableFromReport('xx')
give me this:
NameError Traceback (most recent call last) Cell In[26], line 1 ----> 1 df = pbi.getTableFromReport('绩效')
File c:\Users\tiancom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pbi_local_connector\main.py:80, in getTableFromReport(tableName) 77 conn_str = f'Provider=MSOLAP;Data Source={reportPort};Catalog={reportId};' 78 query = f"""EVALUATE {tableName}""" ---> 80 with Pyadomd(conn_str) as conn: 81 with conn.cursor().execute(query) as cur: 82 df = pd.DataFrame(cur.fetchone(), 83 columns=[i.name.replace(f"{tableName}[", "").replace("]", "") for i in cur.description])
File c:\Users\tiancom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyadomd\pyadomd.py:127, in Pyadomd.init(self, conn_str) 126 def init(self, conn_str:str): --> 127 self.conn = AdomdConnection() 128 self.conn.ConnectionString = conn_str
NameError: name 'AdomdConnection' is not defined
`
Hello, try to clone the last repo version, I slightly changed the ADOMD library path detection. If it doesn't work let me know.
hey, im having the same error as @Juan-hwt had in the beginning: SyntaxError: f-string: unmatched '('
What do I have to do to fix it?
ok, I used @Juan-hwt change for adomdPath and it worked, but I get another error:
df = pbi.getTableFromReport("example")
IndexError Traceback (most recent call last) Cell In[3], line 4 1 import pandas as pd 2 import pbi_local_connector as pbi ----> 4 df = pbi.getTableFromReport("example") 5 print(df)
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pbi_local_connector\main.py:75, in getTableFromReport(tableName)
64 def getTableFromReport(tableName:str) -> pd.DataFrame:
65 """Get a table from PowerBI dataset as pd DataFrame
66 \nReport must be manually opened!
67
(...)
72 pd.DataFrame: table
73 """
---> 75 reportId, reportPort = getReportInfo()
77 conn_str = f'Provider=MSOLAP;Data Source={reportPort};Catalog={reportId};'
78 query = f"""EVALUATE {tableName}"""
File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pbi_local_connector\main.py:60, in getReportInfo() 57 reportPort = f.readline().encode('latin-1').decode('utf-16') 58 f.close() ---> 60 reportId:str = [bddId.split(".1.db.xml")[0] for bddId in os.listdir(pbiPath) if bddId.endswith(".1.db.xml")][0] 61 return (reportId, "localhost:" + reportPort)
IndexError: list index out of range
I run this:
import pbi_local_connector as pbi pbi.getReportInfo()
but give me error tips: Traceback (most recent call last):File c:\Users\tiancom\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\interactiveshell.py:3508 in run_code exec(code_obj, self.user_global_ns, self.user_ns)
Cell In[8], line 1 import pbi_local_connector as pbi
File c:\Users\tiancom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pbi_local_connector__init__.py:1 from .main import getTableFromReport, getReportInfo
File c:\Users\tiancom\AppData\Local\Programs\Python\Python311\Lib\site-packages\pbi_local_connector\main.py:8 adomdPath = f"\Program Files\Microsoft.NET\ADOMD.NET\{next(os.walk("C:\Program Files\Microsoft.NET\ADOMD.NET"))[1][0]}" SyntaxError: f-string: unmatched '('