IMPRov sketch
Instructables portal (static HTML prototype)

Easy · script · python

Python helper: slice the last N hours from a stamped NMEA log

Tiny CLI that cuts a capture window from a timestamped NMEA file for playback or sharing.

scriptAISpython

Materials

Steps

  1. Save the snippet below as nmea_window.py.
  2. Run: python3 nmea_window.py capture.nmea --hours 12 -o last12.nmea
  3. Feed last12.nmea into your playback exporter or share the slice.
#!/usr/bin/env python3
import argparse
from pathlib import Path

ap = argparse.ArgumentParser(description="Slice last N hours from stamped NMEA")
ap.add_argument("log")
ap.add_argument("--hours", type=float, default=12)
ap.add_argument("-o", "--out", required=True)
a = ap.parse_args()

lines = Path(a.log).read_text(errors="replace").splitlines()
stamps = []
for ln in lines:
    parts = ln.split(None, 1)
    if len(parts) != 2: continue
    try: stamps.append(float(parts[0]))
    except ValueError: continue
if not stamps:
    raise SystemExit("no timestamps")
t1 = max(stamps)
t0 = t1 - a.hours * 3600
out = []
for ln in lines:
    parts = ln.split(None, 1)
    if len(parts) != 2: continue
    try: t = float(parts[0])
    except ValueError: continue
    if t0 <= t <= t1:
        out.append(ln)
Path(a.out).write_text("\n".join(out) + "\n")
print(f"wrote {len(out)} lines → {a.out}")

Video tips

Related watch — Marshall Pix4D/DTED2, TAK Syndicate, Meshtastic. Spelling lock: ATAK.

Tip: Keep the raw full capture; only ship the slice.

Related