Created
November 7, 2023 20:35
-
-
Save juandesant/e77b00bccf6cfda04abc3467e75f2531 to your computer and use it in GitHub Desktop.
Export tables from an Access database
This file contains 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
# This script assumes that [mdbtools][1] are installed, for instance with | |
# `brew install mdbtools` | |
# [1]: https://github.com/mdbtools/mdbtools | |
# It also assumes that [pandas][2] and [pandas_access][3] are installed, | |
# [2]: https://pandas.pydata.org/ | |
# [3]: https://pypi.org/project/pandas_access/ | |
# which you can do with | |
# `pip install pandas pandas_access` | |
# or | |
# `pip install pandas_access` | |
# if you already have pandas (i.e., in a Conda environment) | |
# `file_name` contains the full or relative path to the Access file | |
file_name = ‘path_to_access_file.mdb’ | |
for table in mdb.list_tables(file_name): | |
df = mdb.read_table(file_name, table) | |
df.to_excel(f'{file_name}-{table}.xlsx') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment