An Indonesian ID Number Encodes Your Birth Date and Gender - So I Built a Tool That Fact-Checks Spreadsheets With It
Every Indonesian citizen has a NIK: a 16-digit national ID number. Most people treat it as a random string. It isn't.
Digits 7-12 encode the holder's birth date as DDMMYY - and for women, the day is stored as the real day plus 40. So a NIK containing 570890 means: born on the 17th (57 − 40) of August 1990, female.
Which means something interesting: if a spreadsheet has a NIK column and separate birth-date and gender columns, the spreadsheet can contradict itself - and the NIK knows.
That idea became kualitasid, a data-quality profiler and cleaner for Indonesian-format data, built on pandas. It's on PyPI:
pip install kualitasid
The data it was built for
Indonesian spreadsheets have their own flavour of messy:
- Money written as
Rp 5.000.000,7,5 jt("jt" = juta = million), or just4jt - Phone numbers as
0812-3456-7890,+62 857 1111 2222, or62813... - Dates spelled out:
17 Agustus 1990 - NPWP (tax IDs), licence plates (
B 1234 ABC), province names in any format (jabar,Jawa Barat,JABAR)
kualitasid detects each column's type (NIK, NPWP, phone, date, Rupiah amount, plate, province), scores the dataset 0-100, reports invalid/empty/duplicate values, and can clean automatically: Rp 5.000.000 → 5000000, 0812-3456-7890 → +6281234567890, 17 Agustus 1990 → a real date.
The part I actually wanted to build
Detection and cleaning are useful, but the consistency check is the part I cared about. Here is the core of it (from konsistensi.py):
for label, nik_v, lahir_v, jk_v in zip(df.index, df[kolom_nik], lahir, jk):
info = info_nik(nik_v)
if info is None:
continue
tgl = parse_tanggal(lahir_v)
if tgl is not None and (tgl.day, tgl.month, tgl.year % 100) != (
info["hari"], info["bulan"], info["tahun2"]
):
isu.append({"jenis": "nik_tanggal_lahir", "baris": label, ...})
gender = normalize_jk(jk_v)
if gender is not None and gender != info["jenis_kelamin"]:
isu.append({"jenis": "nik_jenis_kelamin", "baris": label, ...})
Two deliberate design choices in there:
- Invalid NIKs are skipped, not double-reported. If a NIK's structure is broken, the profiler already flags it as invalid; the consistency check only works with NIKs that parse. One problem, one report.
- NIKs are always masked in the output (
samarkan_nik). A data-quality report gets emailed around and screenshotted - it should never become a leak of full national ID numbers. Same reason invalid example values for sensitive types (NIK, NPWP, phone) are masked in reports by default.
And one thing it refuses to check: the province digits in a NIK are where the ID was registered, not where the person lives now - so comparing them against a "province" column would manufacture false problems. Knowing what not to check mattered as much as the checks themselves.
A real run
This is the bundled example file - five rows, deliberately dirty:
nama,nik,hp,npwp,plat,gaji,tgl_lahir,jenis_kelamin,provinsi
Siti Aminah,3171015708900002,+62 857 1111 2222,...,7,5 jt,17 Agustus 1990,Laki-laki,DKI Jakarta
Andi Wijaya,3273011503850004,08xx,...,Rp 6.000.000,16-03-1985,Laki-laki,Jawa Barat
$ kualitasid data_kotor.csv --html laporan.html --bersihkan bersih.csv
Skor: 57.8/100
Duplikat: 1 baris
Konsistensi antar kolom: 2 masalah di 2 baris
Both consistency problems are real catches. Siti Aminah's NIK encodes a woman (day 57 = 17 + 40), but the gender column says Laki-laki (male). Andi Wijaya's NIK says 15-03-85, but his birth-date column says 16-03-1985 - off by one day, exactly the kind of typo that survives forever because both values "look fine" on their own.
Reports come out as text, JSON, or a single HTML page; input can be CSV or Excel. Everything runs locally - no data leaves the machine, which felt non-negotiable for a tool that touches national ID numbers.
Honest status
kualitasid is small and opinionated: it knows Indonesian formats and doesn't pretend to know others. Validation is structural only - it can tell you a NIK is well-formed and self-consistent, not that the person exists.
It's at v0.3.0, MIT-licensed, and I'd genuinely like to know what breaks on your data:
If you work with Indonesian datasets - government, fintech, HR, e-commerce - what other formats should it understand? Email and postal codes are on my list; what am I missing?
Comments
No comments yet. Start the discussion.