---
title: Compare with your local data
description: JOIN your own CSV or Parquet files with Queria datasets using the Queria CLI or Python API
---

The Queria CLI and Python API run SQL on DuckDB, so DuckDB functions such as `read_csv` and `read_parquet` read your local files. You can JOIN your files with Queria datasets in one SQL statement.

## Example: add prefecture population to an office list

Say you have an office list `offices.csv` on hand:

```csv
pref,office
東京都,本社
大阪府,西日本支社
福岡県,九州支社
```

JOIN it with e-Stat total population on the prefecture name. The CLI attaches the datasets your SQL names.

```bash
queria sql "
  SELECT o.office, e.area_name, e.value AS population
  FROM read_csv('offices.csv') o
  JOIN e_stat.ssds.a_pref_population e
    ON e.area_name = o.pref
  WHERE e.item_name = 'A1101_総人口' AND e.year = 2024
  ORDER BY population DESC
"
```

To save the result to a file, add `--out`.

```bash
queria sql "..." --out result.parquet
```

## Read Parquet or JSON

Any file format DuckDB can read can be joined the same way.

```bash
queria sql "
  SELECT *
  FROM read_parquet('sales.parquet') s
  JOIN zipcode.main.mart_zipcode z ON z.zipcode = s.zipcode
"
```

## From Python

The [Python API](/en/reference/python-api) takes the same SQL. Your pandas DataFrames can also be read from the SQL in `con.sql` by their variable names.

```python
import queria

con = queria.connect()
df = con.sql("""
  SELECT o.office, e.value AS population
  FROM read_csv('offices.csv') o
  JOIN e_stat.ssds.a_pref_population e ON e.area_name = o.pref
  WHERE e.item_name = 'A1101_総人口' AND e.year = 2024
""").df()
```

:::note
The [MCP server](/en/mcp) can't read files on your computer. To compare with local data, use the CLI or the Python API.
:::
