# External file formats

_This page covers the formats q reaches beyond its own: Parquet through the built-in module, and the interfaces that open up everything Python, Arrow, ODBC, and HDF5 can read._

## Parquet

[Parquet](https://parquet.apache.org/) is a compressed columnar format widely used for interchange with tools such as Spark, pandas, and Arrow. KDB-X reads it through the `pq` module, so you can query a Parquet dataset without converting it first.

Reading Parquet differs from [text](text-files.md) and [binary](binary-files.md) files in that q never loads the file into the heap. `.pq.pq` returns a _virtual table_ that decodes only the column chunks a query asks for, reading them through the operating system page cache. A file much larger than memory therefore stays queryable, and opening one is nearly free. The 138 MB file below costs under 200 KB of heap to open, and never shows up in the `mmap` figure from [`.Q.w`](../../../ref/dotq.md#w-memory-stats).

To try it, take a day of Bitcoin transactions from the [AWS Public Blockchain](https://registry.opendata.aws/aws-public-blockchain/) dataset:
```bash
curl -o btc.parquet "https://aws-public-blockchain.s3.us-east-2.amazonaws.com/v1.0/btc/transactions/date=2014-06-30/part-00000-2fdb59cc-58c4-44f1-9e8c-5692087aa321-c000.snappy.parquet"
```

Import the module, open the file, and query it like a table:
```q
q).pq:use`kx.pq
q)t:.pq.pq`:btc.parquet
q)select n:count i, totalFee:sum fee, avgValue:avg output_value by is_coinbase from t
is_coinbase| n     totalFee avgValue
-----------| -----------------------
0          | 70099 11.8892  9.742962
1          | 132   0        25.09007
```

For the full Parquet-to-q type mapping, the supported compression codecs and encodings, the column-map callback, and support for hive-partitioned datasets, see [Parquet in KDB-X](../../../modules/parquet/overview.md).

The [Arrow interface](https://github.com/KxSystems/arrowkdb) reads and writes Arrow and Parquet formats. To read Parquet, use the built-in `pq` module described earlier; arrowkdb is the option when you need to write Parquet or use Arrow itself.

## ODBC

Many Open Database Connectivity (ODBC) drivers expose files as well as database servers — there are drivers for Microsoft Access databases, Parquet, Microsoft Excel, and more. Install the [ODBC client driver for KDB-X](https://code.kx.com/q/interfaces/q-client-for-odbc/), then open a source with `.odbc.open`. To read an Access database:
```q
q)h:.odbc.open "driver=Microsoft Access Driver (*.mdb, *.accdb);dbq=C:\\mydb.mdb"
```

> **Note — Driver names vary by installation**
>
>
> Use the name of the driver actually installed on your machine, which might differ from the example above.
>
[`.odbc.tables`](https://code.kx.com/q/interfaces/q-client-for-odbc/#tables) lists what the connection offers:
```q
q).odbc.tables h
`aa`bb`cc`dd`ii`nn
```

[`.odbc.eval`](https://code.kx.com/q/interfaces/q-client-for-odbc/#eval) runs SQL over the connection:
```q
q).odbc.eval[h;"select * from aa"]
```

Alternatively [`.odbc.load`](https://code.kx.com/q/interfaces/q-client-for-odbc/#load) pulls the whole database into KDB-X, after which you query it in q rather than SQL.

## HDF5

The [HDF5 adapter](https://github.com/KxSystems/hdf5) reads and writes Hierarchical Data Format version 5 (HDF5) files.

## Custom interfaces

Where no interface exists, [extend KDB-X with C code](../../../ref/languages/using-c-functions.md) to integrate a third-party format directly. To check what already exists, see the full [list of external interfaces](https://code.kx.com/q/interfaces/).

## Next steps

- Read the delimited and fixed-width formats q handles natively in [text files](text-files.md).
- See the full Parquet support in [Parquet in KDB-X](../../../modules/parquet/overview.md).
- Move data between q and Python with [KDB-X Python](../../../get_started/kdb-x-python-overview.md).
