Error trying to access .mdb file

42 views
Skip to first unread message

r...@minerva.kgi.edu

unread,
Jun 3, 2016, 3:14:07 PM6/3/16
to Caffe Users
Hello,
I am using this script to move the information in data.mdb into a csv file:

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
#
# AccessDump.py
# A simple script to dump the contents of a Microsoft Access Database.
# It depends upon the mdbtools suite:
 
import sys, subprocess # the subprocess module is new in python v 2.4
 
DATABASE = sys.argv[1]
 
# Get the list of table names with "mdb-tables"
table_names = subprocess.Popen(["mdb-tables", "-1", DATABASE],
                               stdout=subprocess.PIPE).communicate()[0]
tables = table_names.split('\n')
 
# Dump each table as a CSV file using "mdb-export",
# converting " " in table names to "_" for the CSV filenames.
for table in tables:
    if table != '':
        filename = table.replace(" ","_") + ".csv"
        file = open(filename, 'w')
        print("Dumping " + table)
        contents = subprocess.Popen(["mdb-export", DATABASE, table],
                                    stdout=subprocess.PIPE).communicate()[0]
        file.write(contents)
        file.close()


The problem: When I run the script with data.mdb as an argument I get the error message: File does not appear to be an Access database. 
How can I solve this? Also, what is the file lock.mdb? 
Thank you!
Reply all
Reply to author
Forward
0 new messages