Skip to content

Instantly share code, notes, and snippets.

@0xAungkon
Created July 16, 2025 03:16
Show Gist options
  • Select an option

  • Save 0xAungkon/354e04ef9e2f611a2e9ee51be4f3620f to your computer and use it in GitHub Desktop.

Select an option

Save 0xAungkon/354e04ef9e2f611a2e9ee51be4f3620f to your computer and use it in GitHub Desktop.
read mdb(Microsoft Access) files
import subprocess
import pandas as pd
from io import StringIO
mdb_file = 'att2000.mdb'
att_table_name = 'CHECKINOUT'
user_table_name = 'USERINFO'
def get_df(table_name):
# Export table using mdbtools
result = subprocess.run(['mdb-export', mdb_file, table_name], stdout=subprocess.PIPE, check=True)
csv_data = result.stdout.decode('utf-8')
df = pd.read_csv(StringIO(csv_data))
return df
# Convert CSV to DataFrame
attendence_df=get_df(att_table_name)
user_df=get_df(user_table_name)
attendence_df = attendence_df.merge(
user_df[['USERID', 'Name', 'Badgenumber']],
on='USERID',
how='left'
)
del attendence_df['VERIFYCODE']
del attendence_df['SENSORID']
del attendence_df['Memoinfo']
del attendence_df['UserExtFmt']
del attendence_df['WorkCode']
attendence_df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment