Convert Excel to Parquet with Python
Run this Python script locally with Apache Arrow. The script reads your local file rather than sending it to this website.
Before you start
- Install Python 3 and create an isolated environment using the commands below.
- Place input.xlsx in your working folder. Use a new output filename and keep the original.
- Save the Python code as task.py. On macOS/Linux run .venv/bin/python task.py; on Windows PowerShell run .venv\Scripts\python.exe task.py.
python3 -m venv .venv
.venv/bin/python -m pip install pyarrow openpyxlpy -m venv .venv
.venv\Scripts\python.exe -m pip install pyarrow openpyxlimport pyarrow as pa
import pyarrow.parquet as pq
from openpyxl import load_workbook
book = load_workbook("input.xlsx", read_only=True, data_only=True)
rows = book.active.iter_rows(values_only=True)
headers = list(next(rows))
if any(not isinstance(name, str) or not name for name in headers) or len(set(headers)) != len(headers):
raise ValueError("Expected nonempty unique text column headers")
records = [dict(zip(headers, values)) for values in rows]
names = list(dict.fromkeys(name for row in records for name in row))
table = pa.Table.from_pydict({name: [row.get(name) for row in records] for name in names})
pq.write_table(table, "output.parquet", compression="snappy")
book.close()
print(table.schema)Limits and output
- These examples load the complete table in memory. Use small representative files first; use an explicit Arrow schema when inferred types do not match your intended values.
- The CLI/library examples use their own type mappings, which can differ from this website’s text-column conversion. Keep the source and compare nulls, identifiers, timestamps, decimals and nested values.
- Reads the first worksheet and cached formula results only. openpyxl does not calculate formulas; missing cached values become null. Formatting, macros and additional worksheets are not copied.
Documentation: Apache Arrow Parquet documentation; openpyxl tutorial