open access file in python


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 [1]: import sys, subprocess In [2]: DATABASE = 'Exam_BackUp.mdb' In [3]: table_names = subprocess.Popen(["mdb-tables", "-1", DATABASE], stdout=subprocess.PIPE).communicate()[0] 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.


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()


  • How do I search within a word within a searchable field? “Contains” search
  • SQL update multiple rows on specific ID's
  • How to fork and exec a server and wait until it's ready?
  • os.system not working, but typing the same thing into the command prompt works
  • Git cherry-Pick a batch of commits from a file
  • console.log printing statements in the wrong order for learnyounode node.js tutorial
  • Programmatically check if PHP is installed using Python
  • Which reference source does include Microsoft.VisualBasic?
  • How to Use Two Different PHP Versions on One Server
  • Downloading files from Google Storage using Spark (Python) and Dataproc
  • How to intall Tomcat as a daemon on OS X?
  • Read stdin in chunks in Bash pipe
  • LyX — Title, Abstract, Keywords Missing When Using Elsevier Class in View
  • How do I install a previous version of build tools in addition to the sdk?
  • Determining the length of a read stream in node js
  • subprocess.Popen('start') fails
  • How can I determine if process is 32 or 64Bit from a handle?
  • Can't find cygwin setup.exe file?
  • Unable to set a breakpoint on main while debugging a program compiled with Rust 1.10 with GDB
  • Implementing Oracle.Web.dll, Oracle.DataAccess.dll 64-bit failed on Windows Server 2008 with IIS 7.5
  • How secure are apple APNS push notifications?
  • RegistryKey.GetSubKeyNames returns names that are not in that subkey!
  • triggering user space with kernel
  • Is there a Windows socket API call / option to “block” a range of ports à la SO_EXCLUSIVEADDRUSE
  • How to read piped content in C?
  • Clear fused location provider's location for testing
  • How to make R's read_csv2() recognise the text characters properly
  • Azure table store snapshot/backup capability
  • Bigquery event streaming and table creation
  • Redirect STDERR in OPEN pipe comand. Perl Linux
  • How do I configure context broker accept post requests from my remote sensor?
  • Python CGI os.system causing malformed header
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Linq Objects Group By & Sum
  • Deselecting radio buttons while keeping the View Model in synch
  • Nant, Vault & Windows Integrated Authentication
  • How to handle AllServersUnavailable Exception
  • Can I make an Android app that runs a web view in Chrome 39?
  • Updated Ionic CLI but shows previous version (Windows)
  • Large data - storage and query