piyoparse
piyoparse parses Japanese PiyoLog export text into structured data.
- Rust crate: piyoparse on crates.io
- TypeScript/WebAssembly package:
@necocen/piyoparseon npm - Supports Japanese iOS and Android day/month exports
- Preserves unknown future record types and renamed custom records as
other
This is an unofficial tool and is not affiliated with PiyoLog or its operating company. Do not contact PiyoLog support or the operating company about this library.
本ツールは非公式であり、ぴよログおよびその運営会社とは一切関係ありません。本ライブラリについて、ぴよログのサポート窓口や運営会社へのお問い合わせはお控えください。
Installation
Rust
Or add it to Cargo.toml:
[]
= "0.1"
TypeScript
Rust Usage
use ;
TypeScript Usage
import { parsePiyolog, type ParsedExport } from "@necocen/piyoparse";
const parsed: ParsedExport = parsePiyolog(exportText);
for (const record of parsed.days[0]?.records ?? []) {
if (record.data.kind === "formula") {
console.log(record.time, record.data.amount_ml);
}
}
parsePiyolog returns typed objects directly. parsePiyologJson is also available when a JSON string is easier to pass through an application boundary.
The npm package can be used from browser bundlers and Node.js. Node.js can load the package with either ESM import or CommonJS require.
const = require;
Data Model
The parser returns a ParsedExport:
ParsedExport.days: parsed day blocks from a day or month exportDay.records: timestamped records for that dayDay.summary: summary totals printed by PiyoLogRecord.memo: free-text memo attached to a record, when presentRecord.data: tagged record data
Known PiyoLog record types are represented as RecordData variants in Rust and as discriminated objects in TypeScript. For example, formula records expose amount_ml, wake_up records expose duration_minutes, and breastfeeding records expose left/right minutes, order, and amount when they can be parsed.
Unknown future record types and renamed custom items are parsed as other with the original type_name and raw detail, so the export can still be read even when the parser does not know the record type yet.
Supported Input
piyoparse uses one tolerant parser for both iOS and Android export layouts. Callers do not need to detect the platform first.
Currently supported:
- Japanese PiyoLog exports
- iOS and Android export text
- Day exports and month exports
- Typed parsing for common records such as breastfeeding, formula, expressed breast milk, drink, wake-up, walks, and pumping
- Summary totals for breastfeeding, formula, expressed breast milk, sleep, pee, and poop
Known Limitations
- Only Japanese PiyoLog exports are supported. Exports from other app languages/locales are not supported because record type names, summary labels, and detail text are locale-specific.
- Typed amount parsing supports only milliliters (
ml). Other volume units, such as ounces, are not parsed intoamount_ml. - This crate parses the text export format. It is not a complete model of every field in the PiyoLog app.
Development
Install the local task tools:
Run all tests:
Run Rust lint and wasm target checks:
Build the WebAssembly npm package for local verification or publishing:
This step is for maintainers. Application code should install the published package with npm install @necocen/piyoparse instead of building it locally.
PiyoLog export files can contain meaningful trailing spaces. Fixture .txt files under tests/fixtures/ intentionally keep those spaces, so avoid editing them with tools that automatically trim trailing whitespace.