Tag Archives: sql

Converting MDB to CSV using OOo/LibO

This post explains the steps necessary to convert a Microsoft Access database file into CSV, using OpenOffice.org (or LibreOffice) Base.

  1. OOo can’t open an MDB file natively. You have to create a new ODB file that connects to the MDB file as a “remote” database. Just don’t try to move around the files.

  2. Copy the tables over into a different, native ODF database (ODB) file. This may sound arbitrary, but it’s necessary; otherwise, the next step would either be impossible or unbearable.

  3. Base doesn’t have an “export to CSV” menu entry. You have two options:

    • Run the following SQL command (Tools → SQL…).

      SELECT * INTO TEXT "filename_without_ext" FROM "TableName"

      This command only works on a native ODB because Access’s SQL engine doesn’t support the INTO TEXT construct.

      Note that this actually creates an external table in the database (if it doesn’t show up, reload the database). As a consequence, you can’t use the same name for the CSV file as an existing table.

    • Copy the table into Calc and export it to CSV. This would have been extremely slow if done from the non-native DB.

Credits to the people at an OOoForum.org thread who figured this out.