I am not able to open the access file using python. I am not sure if the problem is with the mdb file or the python commands.
In : import sys, subprocess In : DATABASE = 'Exam_BackUp.mdb' In : table_names = subprocess.Popen(["mdb-tables", "-1", DATABASE], stdout=subprocess.PIPE).communicate() Couldn't open database.
How do I know if the file is microsoft access file? I have checked that mdbtools is installed on my Ubuntu server.
I need to open the (access or fortran) file and save the contents to csv.Answer1:
Why not try opening it with an ODBC driver?
A good example is <a href="http://en.wikibooks.org/wiki/Python_Programming/Database_Programming" rel="nofollow">here</a>, reproducing it for your case would be along the lines of:
import pyodbc DBfile = 'Exam_BackUp.mdb' conn = pyodbc.connect('FILEDSN='+DBfile) cursor = conn.cursor() # Do whatever you want with SQL selects, etc cursor.close() conn.close()