Foundations to Frontier
Tests
C. Programming, Tools and HPC › C7 Scientific Data Formats

Tabular Data: CSV, Parquet and Arrow

Most scientific and engineering tables (telemetry, catalogues, experiment logs, features) start life as CSV, a human-readable text format without types, compression or indexing. Columnar formats fix this: Apache Parquet stores each column contiguously in compressed row groups with type information and statistics, so queries read only the columns and row groups they need, and Apache Arrow defines the matching in-memory layout (contiguous buffers, validity bitmaps, offsets) that libraries share without copying. This topic covers CSV pitfalls, row- versus column-oriented storage, Parquet's row groups, encodings (dictionary, run-length, delta) and compression, predicate pushdown, Arrow buffers, and the tools (pandas, Polars, PyArrow, DuckDB). In the exercises you implement CSV type inference, Arrow string buffers, the encodings and a mini columnar file with statistics-based skipping; then you compare file sizes and query costs for 100 000 rows of spacecraft telemetry across six layouts.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Reading a spreadsheet by columns

If you store a table line by line, like a diary, then to find the average temperature you must read every line, including all the other measurements on it. If you store it column by column, all the temperatures sit together: you read just that column, and because similar numbers sit next to each other, it also shrinks better when compressed. That is the idea behind columnar formats like Parquet.

Row-oriented versus columnar files
layout:
query columns:
the file, byte by byte (each square = one value, colour = column)
values read: 16 of 200 (8%) · values actually wanted: 16
Faded squares are skipped; outlined ones are the answer. A row layout interleaves columns, so even a two-column query reads everything. A columnar layout stores each column contiguously in row groups of 8 rows with min/max statistics, so a reader fetches only the needed columns of the groups whose time range overlaps the query (the filter column is read too). Columns of similar values also compress far better.
Why engineers care

Spacecraft housekeeping telemetry, sensor logs from test campaigns and astronomical catalogues are long, wide tables queried a few columns at a time. Moving them from CSV to Parquet often cuts storage several times and speeds queries by orders of magnitude, while keeping types and units explicit.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A columnar file stores…
  2. 2. Why does a column compress well?
  3. 3. In the demo, how much does a row layout read for a two-column query?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Formats at a glance

Format Layout Types Compression Partial reads
CSV text rows none (strings) external (gzip) no
JSON Lines text rows loose external no
Parquet columnar, row groups yes (logical types) per column (Snappy, Zstd, gzip) columns + row groups
Arrow IPC / Feather columnar, in-memory layout yes optional (LZ4, Zstd) columns, memory-mapped
HDF5 / NetCDF / Zarr chunked arrays yes per chunk slices (C7.2)
import pandas as pd
df = pd.read_csv("telemetry.csv", dtype={"sat_id": "string"}, parse_dates=["time"])
df.to_parquet("telemetry.parquet", engine="pyarrow", compression="zstd", row_group_size=100_000)
cols = pd.read_parquet("telemetry.parquet", columns=["time", "temp"],
                       filters=[("time", ">=", pd.Timestamp("2024-03-01"))])

DuckDB and Polars query Parquet files directly (SELECT avg(temp) FROM 'telemetry/*.parquet' WHERE ...) without loading them.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Which format preserves column types?
  2. 2. read_parquet(columns=[...]) reads…
  3. 3. Arrow is mainly…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

CSV pitfalls

Types are guessed: IDs lose leading zeros (“007” → 7), dates are ambiguous (01/02/2024), missing values come as “”, “NA” or “-999”, floats lose precision when printed with few digits or bloat when printed with 17, and commas or quotes inside fields need correct quoting. Always pass explicit dtypes and NA values, and prefer a typed format for anything beyond small exchanges.

Inside Parquet

A file is a sequence of row groups (typically 64 MB–1 GB); within each, every column chunk is stored contiguously, split into pages. Each column is first encoded (dictionary encoding for low-cardinality values, run-length/bit-packing for repeated values, delta encoding for sorted integers like timestamps) and then compressed. The footer holds the schema and per-chunk statistics (min, max, null count), letting readers skip row groups that cannot match a filter (predicate pushdown). Sorting data by a commonly filtered column makes statistics more selective and runs longer.

Arrow

A column is a set of contiguous buffers: a validity bitmap (1 bit per value), fixed-width values, or for variable-length types an offsets buffer (n + 1 int32/int64) plus one data buffer. pandas, Polars, DuckDB, Spark and GPU libraries exchange Arrow data without copying.

🐍 Exercise 1: CSV, Arrow and a mini Parquet
Show CSV type-inference and quoting behaviour; build Arrow string buffers (validity bitmap, offsets, data) and read values back; implement dictionary, run-length and delta encodings; write a columnar file with row groups, per-column zlib buffers and min/max statistics in a JSON footer, and read selected columns with statistics-based row-group skipping, counting bytes read.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Which encoding suits a column of mostly repeated status codes?
  2. 2. Predicate pushdown uses…
  3. 3. Arrow offsets for strings 'sat', null, 'orbit'?

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Designing tables for analysis

  • Partition large datasets into many Parquet files by a coarse key (date, satellite, campaign): telemetry/sat=7/date=2024-03-01/part-0.parquet; engines prune whole directories.
  • Sort within files by the main filter key for tight statistics and long runs.
  • Store at the right precision: a temperature measured to 0.01 °C does not need 17 significant digits; scaled integers or float32 compress far better.
  • Units and metadata: keep units, frames and provenance in the schema metadata or a data dictionary, not in column names alone.
  • Avoid many tiny files (C4.1): aim for files of hundreds of MB.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Partitioning by date lets a query for one day…
  2. 2. Sorting a file by time improves…
  3. 3. Why store sensor readings at sensor precision?

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Tabular formats, measured

Exercise 1. Naive inference turns “007” into 7; the csv module round-trips commas and quotes but returns numbers as strings. Arrow stores “sat”, null, “orbit” as bitmap 0b101, offsets 0, 3, 3, 8 and 8 data bytes. Dictionary + RLE turn OK, OK, SAFE, OK, OK, OK into three runs; 1000 timestamps at a 10 s cadence delta-encode to a single repeated value. A 10 000-row, 4-column columnar file answers “temp where 2500 ≤ time ≤ 3499” by reading 17.8 kB of its 162 kB (11%): two row groups, two columns.

Exercise 2: six layouts for 100 000 telemetry rows (1 s timestamps, drifting temperature, noisy voltage, rarely changing mode and satellite id; zlib level 6; 10 000-row groups):

Layout Size vs CSV
CSV 5.22 MB 1×
CSV + zlib 1.93 MB 2.7×
binary rows + zlib 1.68 MB 3.1×
columnar, uncompressed 2.60 MB 2.0×
columnar + zlib 1.51 MB 3.5×
columnar + delta/RLE encodings + zlib 1.36 MB 3.8×
columnar, sensor-precision integers + encodings + zlib 0.21 MB 24.8×

Per column in the encoded file: time 1.4 kB, mode 0.4 kB, satellite 0.2 kB, while temperature and voltage take 674 and 686 kB: full-precision floats carry noise digits that no compressor removes, so storing values at their measurement resolution is the largest single gain. A query for the mean temperature over the first 10% of time reads 68 kB from the columnar file versus 5.2 MB of CSV (77×) or 1.7 MB of compressed binary rows. (Compressed sizes can differ slightly between zlib builds.)

🐍 Exercise 2 (research): six ways to store a telemetry table
Generate 100 000 rows of telemetry; measure the size of CSV, compressed CSV, compressed binary rows, uncompressed columns, compressed columns, columns with delta and run-length encodings, and columns stored as sensor-precision integers; break the encoded size down per column; and compute the bytes a time-range query must read in each layout.

Tabular formats in AI, robotics and aerospace

  • Housekeeping telemetry archives in Parquet partitioned by spacecraft and day, queried with DuckDB or Spark.
  • Astronomical catalogues (Gaia, LSST) distributed as Parquet/HATS for column-oriented queries.
  • ML feature stores and experiment logs built on Parquet and Arrow.
  • Robotics logs: ROS bag data converted to columnar tables for analysis (MCAP exports).

References

  1. Apache Parquet documentation (parquet.apache.org): file format, encodings, statistics.
  2. Apache Arrow documentation (arrow.apache.org): columnar format specification.
  3. D. Abadi, S. Madden, N. Hachem (2008). “Column-stores vs. row-stores: how different are they really?” SIGMOD.
  4. M. Raasveldt, H. Mühleisen (2019). “DuckDB: an embeddable analytical database.” SIGMOD (demo).
  5. RFC 4180 (2005). Common Format and MIME Type for Comma-Separated Values (CSV) Files.