Last active
October 4, 2018 18:14
-
-
Save drheinheimer/334bf958ca2064642cd81d1e0cb4b9b2 to your computer and use it in GitHub Desktop.
Read a Paradox database table (for example from WEAP)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pypxlib import Table | |
def db(dir, name): | |
filelist = os.listdir(dir) | |
dbname = '{}.db'.format(name) | |
dbname = dbname if dbname in filelist else dbname.replace('.db', '.DB') | |
if dbname not in filelist: | |
return | |
mbname = dbname.replace('.db', '.MB').replace('.DB', '.MB') | |
if mbname not in filelist: | |
mbname = None | |
file_path = os.path.join(dir, dbname) | |
blob_file_path = os.path.join(dir, mbname) if mbname else None | |
return Table(file_path=file_path, blob_file_path=blob_file_path) | |
data = db('./SJN_R3', 'Data') | |
with data as table: | |
for row in table: | |
print(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment