Once I had my wine rack as a text file, one question kept coming back that the file itself does not answer: what goes off first? You can ask a model every time, and every time you get a slightly different answer. For something you want to know weekly, that is the wrong shape.
A script gives you the same answer every time. And when the answer is wrong, it is reproducibly wrong, which is far easier to fix.
The job
A file with bottles in it, and one command that says which one should be opened now. Runs on my own machine, sends nothing anywhere, and works off a list I keep by hand.
The hard part is not the arithmetic. It is that a cellar list is messy. Names with commas in them, champagne without a vintage, a bottle whose year you never filled in.
My actual prompt
Write a Node script that reads a CSV of my cellar and sorts by what should
be opened first.
Columns: name, year, style, count. Names can contain a comma.
Use a closed list of styles with a fixed drinking window per style.
Do not recognise grape varieties and do not guess from the name.
On an empty or impossible value: skip the row, say which row and why,
and exit with an error code. Never invent a year.
Champagne without a vintage: count from the year of purchase and state
that you are making that assumption.
The full script is at sparkone.nl/tools/drinkvenster.mjs, with a sample file next to it. You run it like this:
node drinkvenster.mjs kelder.csv
And it prints this:
TE LAAT 2022-2023 3x Provence rose
nu open 2024-2026 6x Muscadet Sevre et Maine
op dreef 2020-2031 2x Barolo Serralunga
Niet meegerekend:
regel 8: Rioja Gran Reserva — onbekende stijl "rood zwaar"
regel 11: Vergeten fles — jaar "" is leeg of onmogelijk
The labels are Dutch because it is my cellar. Change the strings at the top of the file if that bothers you.
Taken apart
Three instructions carry this script, and they transfer to any job that runs on your own messy data.
A closed list instead of recognition. The model wanted to pull grape varieties out of the name and find a window for each. That works impressively on the first ten bottles and quietly fails on the eleventh. Eight styles you assign yourself are duller and they are right.
Fail loudly rather than compute through. An empty cell is not a zero. Software fills that in by default, and in a cellar that means a bottle sitting neatly in the list with an invented year behind it. So the instruction is explicit: skip it, name the row, exit with a code.
Make assumptions visible. Champagne without a vintage has to be counted from something. That is fine, as long as the line says it is an assumption. The moment assumptions go quiet, an estimate starts looking like a measurement.
What broke
Testing turned up three things.
The first row in my own file is “Domaine des Roches, Chenin”. A script that splits on commas turns that into two columns and shifts everything along. The model had solved it by moving the name to the end, which works until someone reorders the columns. It ended up as a small parser that respects quotes, fifteen lines, after which the order stops mattering.
Second: my list used “rood zwaar” and the script only knew “rood stevig”. It dropped out with an error line, exactly as intended. My first instinct was to widen the list. That is the wrong instinct, because then it grows with every bottle until recognition is back to guessing. I changed my CSV instead.
The third is about the wine. My 2021 rosé came out labelled TE LAAT, and I am still drinking it happily. The two-year window is strict. That is not a bug in the code but a choice in the table, and that difference is the whole point of doing it this way: you can point at exactly where the judgement lives, and it takes one line to change it.
Ethics note
The windows in this script come from experience and rules of thumb, not from research. They sit at the top of the file on purpose, so you can see they are an opinion rather than physics. A model that gives you the same answer in a sentence hides that same opinion inside fluent prose.
Everything here also stays on your own machine, which matters more than it sounds. A stock list says what is standing in your house and roughly what it is worth. That is exactly the kind of file you do not paste into a chat window belonging to a service whose retention policy you have never read.
And the honest caveat about the genre: this script is ninety lines because my cellar is small. If you own twelve bottles, a text file does the same job and this is a hobby.
Take it
Start with five rows in a CSV and run it. If the output surprises you, either your list is wrong or the table is wrong, and both are worth knowing.
The empty prompt for your own subject:
Write a script that reads [my file] and sorts by [what is most urgent].
Use a closed list of [categories] with a fixed [rule] per category.
Recognise nothing from free text and do not guess.
On an empty or impossible value: skip the row, say which row and why,
and exit with an error code.
Wherever you make an assumption, put that assumption in the output.
Small exercise: take a list you already keep, find the messiest row, and see what happens when you use it as your first test row instead of your last.
