Read the source and its declared rule
The supplied extracted-cell record includes kind and value. An error cell containing #N/A must be held with that error retained. A text cell whose literal wording is #N/A is not the same input kind; a blank cell is represented separately as null.
| Record | Input JSON |
|---|---|
| Base input | {"kind":"error","value":"#N/A"} |
Compare the actual paths
Bad output accepts an empty string, hiding the source fault. Good output holds source-cell-error with original #N/A instead of converting it into missing data.
| Path | Output JSON |
|---|---|
| Misleading path | {"accepted":true,"value":""} |
| Corrected path | {"accepted":false,"error":"source-cell-error","original":"#N/A"} |
import {DatabaseSync} from 'node:sqlite';
import {TextDecoder} from 'node:util';
import {inflateSync} from 'node:zlib';
import {posix} from 'node:path';
import {createHash} from 'node:crypto';
const rows=(db,sql)=>db.prepare(sql).all().map(r=>({...r}));
const failed=(action)=>{try{action();return null;}catch(e){return {code:e.errcode??e.code??e.name};}};
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(i.kind==='error')return corrected?{accepted:false,error:'source-cell-error',original:i.value}:{accepted:true,value:''};
return {accepted:true,value:i.kind==='blank'?null:i.value};
};
const cases=[{"label":"misleading base","input":{"kind":"error","value":"#N/A"},"expected":{"accepted":true,"value":""},"corrected":false},{"label":"corrected base","input":{"kind":"error","value":"#N/A"},"expected":{"accepted":false,"error":"source-cell-error","original":"#N/A"},"corrected":true},{"label":"literal text resembles error","input":{"kind":"text","value":"#N/A"},"expected":{"accepted":true,"value":"#N/A"},"corrected":true},{"label":"genuine blank cell","input":{"kind":"blank","value":null},"expected":{"accepted":true,"value":null},"corrected":true}];
for(const test of cases){
const actual=run(test.input,test.corrected);
assert.deepEqual(actual,test.expected,test.label);
console.log(test.label,actual);
}
Check boundaries before the next load
Literal text #N/A is accepted as text. A genuine blank is accepted as null under this optional-cell contract.
| Case | Input JSON | Expected output JSON |
|---|---|---|
| Literal error-looking text | {"kind":"text","value":"#N/A"} | {"accepted":true,"value":"#N/A"} |
| Genuine blank cell | {"kind":"blank","value":null} | {"accepted":true,"value":null} |
Are error #N/A and text #N/A interchangeable?
Show the worked answer
No. Their source kinds differ. Hold the error record and preserve the ordinary text record.