
Extracting Time Series From XML Sensor Files With Pandas
Turn XML sensor readings into a pandas time series, resample to hourly means, find a 50 minute gap and a silent switch from Celsius to Fahrenheit.
Everything you need to level up your coding skills.

Turn XML sensor readings into a pandas time series, resample to hourly means, find a 50 minute gap and a silent switch from Celsius to Fahrenheit.

Convert one awkward CSV to JSON, JSON Lines, XML, YAML, Excel, Parquet, Markdown and SQL, read each back and see the cost on 193,708 rows.

Count 400,000 orders by status in a 132 MB XML file with grep in 0.4 s, lxml iterparse in 2.0 s or xmlstarlet in 5.1 s, and know when each can be trusted.

Total 5,000 XML invoice files in under a second with Python, xmlstarlet or grep, group by currency, and catch malformed files and missing totals.

A method for turning an XML file into answers: inspect its shape, extract the fields once, check counts and totals, join carefully and record the result.

A 132 MB XML file became 12.1 MB of Parquet. A grouped query ran in 19 ms against seconds of reparsing. How to write it, and when CSV or a database wins.

Spark 4.0 reads XML natively with rowTag. Tested on 100,000 orders: schema inference, explode for lines, the double precision trap and from_xml for strings.

BigQuery has no XML loader or functions. Two routes: a JavaScript UDF with fast-xml-parser, tested here in Node, or parsing before the load to Parquet.

Snowflake loads XML into VARIANT with a file format of TYPE XML, and XMLGET plus FLATTEN turn it into rows. The statements, the data shape and the limits.

How to get XML into Snowflake, BigQuery, Spark, DuckDB and a lake: keep raw files, parse once with a typed schema, store Parquet and reconcile counts.

A partner asks for XML for a flat table. Measured on 100,000 rows, XML was 2.7 times the CSV size, though gzip nearly erased the gap. When each is right.

One small config written three ways: size, comments, types and the YAML country code that parses as False. A decision guide for choosing between them.
We send one email when a new article is published. No spam.