Skip to content

laddercodec

The compatibility layer for CLICK ladder data. laddercodec reads and writes CLICK's native representations and enables reliable round-tripping between CLICK and the pyrung/ClickNick toolchain. Tested against captures from v2.60 through v4. Zero runtime dependencies.

It's the layer ClickNick pastes through, and it's useful on its own to convert between CLICK ladder data, Python objects, and CSV.

Install

uv add laddercodec
# or
pip install laddercodec

Requires Python 3.11+.

Quick example

from laddercodec import read_csv, encode, decode

# CSV → binary (ready to paste into Click)
rungs = read_csv("my_rung.csv")
binary = encode(rungs[0])

# Binary → structured data: one Rung per rung on the clipboard
[rung] = decode(binary)
print(rung.logical_rows)
print(rung.instructions)

What's included

Encoder — encode() takes Rung objects or canonical CSV and produces clipboard binary ready to paste into Click. Supports all standard instruction types, including those new in CLICK v4, wire topologies, and styled comments.

Decoder — decode() reads clipboard binary back into structured Python objects (contacts, coils, timers, wires, comments). decode_program() reads ladder data from native CLICK program files. find_v4_only() lists the instructions that need CLICK v4; check() reports the rungs CLICK's syntax check cannot lay out.

Line check — check() reports the rungs CLICK's syntax check would reject or redraw, before you paste. On a whole program or project, it also reports the For/Next, Call, End and Return rules (Check a program or a project).

CSV I/O — read_csv() and write_csv() convert between the 33-column canonical CSV format and Rung objects. Multi-file program bundles supported.

CLICK format reference — Technical reference for CLICK's native clipboard and program representations, including binary layouts and instruction records.

Status

laddercodec is beta for clipboard encode/decode, CSV I/O, and decode_program().

Email, Home, PositionMove, and VelocityMove still intentionally surface as raw(...) passthroughs so clipboard and program data round-trips stay lossless while those families remain opaque.

Guide overview

Section What's in it
Guides Encoding, decoding, CSV format
Contributing Adding instruction types, debugging a failed paste
Internals Binary format spec, wire rendering rules, instruction blob structure
API Reference Auto-generated from docstrings