0

I was successful in opening a paradox .db file using PyPxLib and now I am searching for some type of code to insert the rows into a Pandas dataframe.

    from pypxlib import Table


    table = Table('d:/Projects/Lakeport/Data/bbrptfav.db')

    try:
          for row in table:
                print(row)
    finally:
          table.close()

The resulting data prints out as follows:

    Row(Account Code='.5')
    Row(Account Code='01', Account Description='PLAN CHECK')
    Row(Account Code='02', Account Description='BUILDING PERMIT FEE')

I would like the resulting data to be inserted into a dataframe

Thank you

PMelan
  • 23
  • 4

1 Answers1

0

Seems like the Table and the Row classes are roughly an OrderedDict. So, can you try this ?

df = pd.DataFrame(table, columns=table.fields.keys()) #or pd.DataFrame(table)
#or df = pd.DataFrame([dict(row) for row in table], columns=table.fields.keys())
#or df = pd.DataFrame([row.items() for row in table], columns=table.fields.keys())

This should give you the following DataFrame :

print(df)

  Account Code  Account Description
0           .5                  NaN
1           01           PLAN CHECK
2           02  BUILDING PERMIT FEE
Timeless
  • 22,580
  • 4
  • 12
  • 30