data-analyst-mcp 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/_irs-soi_catalog.d.ts +42 -0
- package/dist/adapters/_irs-soi_catalog.js +318 -0
- package/dist/adapters/_irs-soi_catalog.js.map +1 -0
- package/dist/adapters/_irs-soi_eo.d.ts +10 -0
- package/dist/adapters/_irs-soi_eo.js +249 -0
- package/dist/adapters/_irs-soi_eo.js.map +1 -0
- package/dist/adapters/_irs-soi_tables.d.ts +83 -0
- package/dist/adapters/_irs-soi_tables.js +505 -0
- package/dist/adapters/_irs-soi_tables.js.map +1 -0
- package/dist/adapters/irs-soi.js +68 -0
- package/dist/adapters/irs-soi.js.map +1 -1
- package/dist/core/tabular.d.ts +16 -3
- package/dist/core/tabular.js +87 -4
- package/dist/core/tabular.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/guide/references/routing.md +4 -1
- package/package.json +1 -1
- package/packs/irs-soi/docs/estimate_patterns.md +95 -0
- package/packs/irs-soi/endpoints.json +96 -0
- package/packs/irs-soi/policy.json +69 -7
- package/packs/irs-soi/source.md +118 -11
- package/packs/irs-soi/tables.json +1439 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* irs-soi exempt organizations: the Exempt Organizations Business Master File extract (EO BMF, every organization
|
|
3
|
+
* recognized as tax-exempt, one CSV per state, updated monthly) and the SOI annual extracts of Form 990, 990-EZ and
|
|
4
|
+
* 990-PF financial data (one zip per form and filing year, 10-57 MB holding a CSV of up to 250 MB).
|
|
5
|
+
*
|
|
6
|
+
* Checked 2026-11-08:
|
|
7
|
+
* EO BMF https://www.irs.gov/pub/irs-soi/eo_{st}.csv (50 states, DC, pr, xx = international), 28 columns;
|
|
8
|
+
* listed on /charities-non-profits/exempt-organizations-business-master-file-extract-eo-bmf
|
|
9
|
+
* extracts listed on /statistics/soi-tax-stats-annual-extract-of-tax-exempt-organization-financial-data:
|
|
10
|
+
* {yy}eoextract990.zip, {yy}eoextractez.zip (24eoextract990EZ.zip), {yy}eoextract990pf.zip (2018-2024);
|
|
11
|
+
* {yy}eofinextract990.zip ... (2012-2017; some years hold a fixed-width .dat file, not read here)
|
|
12
|
+
* EINs are text with leading zeros (the 990-PF CSV drops them: they are restored to 9 digits). The extract CSV is
|
|
13
|
+
* read as a stream from the zip, so only the asked rows are kept.
|
|
14
|
+
*/
|
|
15
|
+
import { Unzip, UnzipInflate } from "fflate";
|
|
16
|
+
import { DataError } from "../core/http.js";
|
|
17
|
+
import { pyStr } from "../core/py.js";
|
|
18
|
+
import { decodeText, readCsv } from "../core/tabular.js";
|
|
19
|
+
import { pageLinks } from "./_irs-soi_tables.js";
|
|
20
|
+
import { state, StateError } from "./_dol_states.js";
|
|
21
|
+
const BASE = "https://www.irs.gov/pub/irs-soi";
|
|
22
|
+
export const BMF_PAGE = "https://www.irs.gov/charities-non-profits/exempt-organizations-business-master-file-extract-eo-bmf";
|
|
23
|
+
export const EXTRACT_PAGE = "https://www.irs.gov/statistics/soi-tax-stats-annual-extract-of-tax-exempt-organization-financial-data";
|
|
24
|
+
const FORMS = {
|
|
25
|
+
"990": /^(\d\d)eo(fin)?extract990\.zip$/i, "990ez": /^(\d\d)eo(fin)?extract(990)?ez\.zip$/i, "990pf": /^(\d\d)eo(fin)?extract990pf\.zip$/i
|
|
26
|
+
};
|
|
27
|
+
const blank = (v) => v === null || v === undefined || v === "" || (Array.isArray(v) && !v.length);
|
|
28
|
+
const list = (v) => (blank(v) ? [] : (Array.isArray(v) ? v : [v]).map((x) => pyStr(x).trim()).filter(Boolean));
|
|
29
|
+
const ein9 = (s) => s.replace(/\D/g, "").padStart(9, "0");
|
|
30
|
+
/** The Form 990 extract file names (an uploaded zip's name tells its form and year). */
|
|
31
|
+
export const EXTRACT_FILES = FORMS;
|
|
32
|
+
/** USPS codes of the `state` parameter (also PR and XX = international). */
|
|
33
|
+
function bmfStates(p) {
|
|
34
|
+
return list(p.state).map((s) => {
|
|
35
|
+
const k = s.toUpperCase();
|
|
36
|
+
return k === "PR" || k === "XX" ? k : state(s, "usps");
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function checkEo(r) {
|
|
40
|
+
const p = r.params || {};
|
|
41
|
+
const name = JSON.stringify(r.name ?? null);
|
|
42
|
+
const probs = [];
|
|
43
|
+
let sts = [];
|
|
44
|
+
try {
|
|
45
|
+
sts = bmfStates(p);
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
if (!(e instanceof StateError))
|
|
49
|
+
throw e;
|
|
50
|
+
probs.push(`request ${name}: ${e.message}`);
|
|
51
|
+
}
|
|
52
|
+
if (r.endpoint === "eo_bmf") {
|
|
53
|
+
if (!sts.length)
|
|
54
|
+
probs.push(`request ${name}: eo_bmf needs state (USPS code or name, PR, or XX for international): one file per state`);
|
|
55
|
+
if (sts.length > 10)
|
|
56
|
+
probs.push(`request ${name}: ${sts.length} states is one file each; ask for 10 or fewer per request`);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const form = pyStr(p.form ?? "990").toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
60
|
+
if (!(form in FORMS))
|
|
61
|
+
probs.push(`request ${name}: form is 990, 990ez or 990pf`);
|
|
62
|
+
if (blank(p.year) && blank(p.filing_year))
|
|
63
|
+
probs.push(`request ${name}: eo_extract needs year (the filing year of the extract, 2012-2024)`);
|
|
64
|
+
if (!list(p.ein).length && !sts.length) {
|
|
65
|
+
probs.push(`request ${name}: eo_extract needs ein (one or more EINs) or state (organizations of that state, from the EO BMF): ` +
|
|
66
|
+
"the national file has about 300,000 rows of up to 246 columns");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return probs;
|
|
70
|
+
}
|
|
71
|
+
// ---------------------------------------------------------------------- EO BMF
|
|
72
|
+
async function bmf(get, st) {
|
|
73
|
+
const body = await get(`${BASE}/eo_${st.toLowerCase()}.csv`);
|
|
74
|
+
const text = decodeText(new Uint8Array(body));
|
|
75
|
+
if (/^\s*</.test(text))
|
|
76
|
+
throw new DataError(`eo_${st.toLowerCase()}.csv: got an HTML page instead of the CSV`, "api");
|
|
77
|
+
return readCsv(text);
|
|
78
|
+
}
|
|
79
|
+
export async function fetchBmf(r, get, limit, notes) {
|
|
80
|
+
const p = r.params || {};
|
|
81
|
+
const eins = new Set(list(p.ein).map(ein9));
|
|
82
|
+
const ntee = list(p.ntee).map((s) => s.toUpperCase());
|
|
83
|
+
const sub = new Set(list(p.subsection).map((s) => s.padStart(2, "0")));
|
|
84
|
+
const nameq = list(p.name).map((s) => s.toLowerCase());
|
|
85
|
+
const cols = list(p.columns).map((s) => s.toUpperCase());
|
|
86
|
+
const out = [];
|
|
87
|
+
for (const st of bmfStates(p)) {
|
|
88
|
+
const rows = await bmf(get, st);
|
|
89
|
+
if (rows.length && !("EIN" in rows[0]))
|
|
90
|
+
throw new DataError(`eo_${st.toLowerCase()}.csv has no EIN column: the layout changed`, "api");
|
|
91
|
+
let kept = 0;
|
|
92
|
+
for (const row of rows) {
|
|
93
|
+
if (eins.size && !eins.has(ein9(String(row.EIN))))
|
|
94
|
+
continue;
|
|
95
|
+
if (ntee.length && !ntee.some((n) => String(row.NTEE_CD || "").toUpperCase().startsWith(n)))
|
|
96
|
+
continue;
|
|
97
|
+
if (sub.size && !sub.has(String(row.SUBSECTION || "").padStart(2, "0")))
|
|
98
|
+
continue;
|
|
99
|
+
if (nameq.length && !nameq.some((n) => `${row.NAME} ${row.SORT_NAME}`.toLowerCase().includes(n)))
|
|
100
|
+
continue;
|
|
101
|
+
if (out.length >= limit) {
|
|
102
|
+
notes.push(`${r.name}: stopped at ${limit} rows (max_rows); filter with ntee, subsection, ein or name`);
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
out.push(cols.length ? Object.fromEntries(Object.entries(row).filter(([k]) => k === "EIN" || k === "NAME" || k === "STATE" || cols.includes(k))) : row);
|
|
106
|
+
kept++;
|
|
107
|
+
}
|
|
108
|
+
notes.push(`${r.name}: eo_${st.toLowerCase()}.csv (${BASE}/eo_${st.toLowerCase()}.csv): ${rows.length} organizations, ${kept} kept`);
|
|
109
|
+
}
|
|
110
|
+
notes.push(`${r.name}: EO BMF codes (SUBSECTION, FOUNDATION, ASSET_CD, INCOME_CD, NTEE_CD ...) are explained in ` +
|
|
111
|
+
"https://www.irs.gov/pub/foia/ig/tege/eo-info.pdf; ASSET_AMT, INCOME_AMT, REVENUE_AMT are " +
|
|
112
|
+
"whole dollars from the latest return on file (TAX_PERIOD), not one common year");
|
|
113
|
+
return out;
|
|
114
|
+
}
|
|
115
|
+
// ---------------------------------------------------------------------- Form 990 extracts
|
|
116
|
+
/** CSV records from text chunks (quoted fields, any line end): a small streaming reader. */
|
|
117
|
+
class CsvStream {
|
|
118
|
+
onRecord;
|
|
119
|
+
field = "";
|
|
120
|
+
rec = [];
|
|
121
|
+
quoted = false;
|
|
122
|
+
afterQuote = false;
|
|
123
|
+
constructor(onRecord) {
|
|
124
|
+
this.onRecord = onRecord;
|
|
125
|
+
}
|
|
126
|
+
push(s) {
|
|
127
|
+
for (let i = 0; i < s.length; i++) {
|
|
128
|
+
const ch = s[i];
|
|
129
|
+
if (this.quoted) {
|
|
130
|
+
if (ch === '"') {
|
|
131
|
+
if (s[i + 1] === '"')
|
|
132
|
+
(this.field += '"', i++);
|
|
133
|
+
else
|
|
134
|
+
(this.quoted = false, this.afterQuote = true);
|
|
135
|
+
}
|
|
136
|
+
else
|
|
137
|
+
this.field += ch;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (ch === '"' && !this.field)
|
|
141
|
+
this.quoted = true;
|
|
142
|
+
else if (ch === ",")
|
|
143
|
+
(this.rec.push(this.field), this.field = "", this.afterQuote = false);
|
|
144
|
+
else if (ch === "\n" || ch === "\r") {
|
|
145
|
+
if (ch === "\r" && s[i + 1] === "\n")
|
|
146
|
+
i++;
|
|
147
|
+
this.end();
|
|
148
|
+
}
|
|
149
|
+
else
|
|
150
|
+
this.field += ch;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
end() {
|
|
154
|
+
if (this.rec.length || this.field) {
|
|
155
|
+
this.rec.push(this.field);
|
|
156
|
+
this.onRecord(this.rec);
|
|
157
|
+
}
|
|
158
|
+
this.rec = [];
|
|
159
|
+
this.field = "";
|
|
160
|
+
this.afterQuote = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export async function fetchExtract(r, get, limit, notes) {
|
|
164
|
+
const p = r.params || {};
|
|
165
|
+
const form = pyStr(p.form ?? "990").toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
166
|
+
const year = Number(pyStr(p.year ?? p.filing_year));
|
|
167
|
+
const links = pageLinks((await get(EXTRACT_PAGE)).toString("utf8"), EXTRACT_PAGE).filter((l) => FORMS[form].test(l.file));
|
|
168
|
+
const link = links.find((l) => l.year === year);
|
|
169
|
+
if (!link) {
|
|
170
|
+
throw new DataError(`request ${JSON.stringify(r.name)}: no Form ${form} extract for ${year} on ${EXTRACT_PAGE} (posted: ` +
|
|
171
|
+
`${[...new Set(links.map((l) => l.year))].sort().join(", ")})`, "not_found");
|
|
172
|
+
}
|
|
173
|
+
// the EINs to keep: asked, or every organization of the asked states (EO BMF)
|
|
174
|
+
const eins = new Set(list(p.ein).map(ein9));
|
|
175
|
+
for (const st of bmfStates(p))
|
|
176
|
+
for (const row of await bmf(get, st))
|
|
177
|
+
eins.add(ein9(String(row.EIN)));
|
|
178
|
+
if (bmfStates(p).length)
|
|
179
|
+
notes.push(`${r.name}: state filter = the EINs in the current EO BMF of ${bmfStates(p).join(", ")} (` +
|
|
180
|
+
"organizations that moved or lost exemption since filing are missed)");
|
|
181
|
+
const cols = list(p.columns).map((c) => c.toLowerCase());
|
|
182
|
+
const zip = await get(link.url);
|
|
183
|
+
const out = [];
|
|
184
|
+
let head = null, einAt = -1, keep = [], seen = 0, member = "", truncated = false;
|
|
185
|
+
const csv = new CsvStream((rec) => {
|
|
186
|
+
if (!head) {
|
|
187
|
+
head = rec.map((h) => h.trim());
|
|
188
|
+
einAt = head.findIndex((h) => h.toLowerCase() === "ein");
|
|
189
|
+
if (einAt < 0)
|
|
190
|
+
throw new DataError(`${link.file}: no EIN column (columns: ${head.slice(0, 8).join(", ")})`, "api");
|
|
191
|
+
keep = head.map((h, i) => [h, i]).filter(([h, i]) => !cols.length || i === einAt || cols.includes(h.toLowerCase())).map(([, i]) => i);
|
|
192
|
+
const missing = cols.filter((c) => !head.some((h) => h.toLowerCase() === c));
|
|
193
|
+
if (missing.length)
|
|
194
|
+
notes.push(`${r.name}: ${link.file} has no column ${missing.join(", ")} (see ${year % 100}eofinextractdoc.xlsx)`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
seen++;
|
|
198
|
+
if (truncated || !eins.has(ein9(rec[einAt] || "")))
|
|
199
|
+
return;
|
|
200
|
+
if (out.length >= limit) {
|
|
201
|
+
truncated = true;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const o = {};
|
|
205
|
+
for (const i of keep)
|
|
206
|
+
o[head[i]] = i === einAt ? ein9(rec[i] || "") : (rec[i] ?? "").trim();
|
|
207
|
+
out.push(o);
|
|
208
|
+
});
|
|
209
|
+
const dec = new TextDecoder("windows-1252");
|
|
210
|
+
const uz = new Unzip();
|
|
211
|
+
uz.register(UnzipInflate);
|
|
212
|
+
let failed = null;
|
|
213
|
+
uz.onfile = (f) => {
|
|
214
|
+
if (member || !/\.(csv|txt)$/i.test(f.name)) {
|
|
215
|
+
if (!member && /\.dat$/i.test(f.name))
|
|
216
|
+
failed = new DataError(`${link.file} holds a fixed-width file (${f.name}), not a CSV; ` +
|
|
217
|
+
"this filing year is not read here (use 2018 or later, or the manual route with the year's layout file)", "bad_request");
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
member = f.name;
|
|
221
|
+
f.ondata = (err, chunk, final) => {
|
|
222
|
+
if (err || failed) {
|
|
223
|
+
failed ??= err;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
csv.push(dec.decode(chunk, { stream: !final }));
|
|
228
|
+
if (final)
|
|
229
|
+
csv.end();
|
|
230
|
+
}
|
|
231
|
+
catch (e) {
|
|
232
|
+
failed = e;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
f.start();
|
|
236
|
+
};
|
|
237
|
+
uz.push(new Uint8Array(zip), true);
|
|
238
|
+
if (failed)
|
|
239
|
+
throw failed;
|
|
240
|
+
if (!member)
|
|
241
|
+
throw new DataError(`${link.file}: no CSV member in the zip`, "api");
|
|
242
|
+
notes.push(`${r.name}: ${link.file} (${link.url}), ${member}: ${seen} returns, ${out.length} kept; amounts in whole dollars; ` +
|
|
243
|
+
`field definitions in ${BASE}/${String(year % 100).padStart(2, "0")}eofinextractdoc.xlsx; the extract year is the year the ` +
|
|
244
|
+
"returns were filed/processed (tax periods vary: see the tax period column)");
|
|
245
|
+
if (truncated)
|
|
246
|
+
notes.push(`${r.name}: stopped at ${limit} rows (max_rows)`);
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=_irs-soi_eo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_irs-soi_eo.js","sourceRoot":"","sources":["../../src/adapters/_irs-soi_eo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,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AM,IAAI,SAAS,CAAC,GAAG,IAAI,CAAC,IAAI,4BAA4B,EAAE,KAAK,CAAC,CAAC;IAClF,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,GAAG,MAAM,MAAM,KAAK,IAAI,aAAa,GAAG,CAAC,MAAM,mCAAmC;QAC5H,wBAAwB,IAAI,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,yDAAyD;QAC5H,4EAA4E,CAAC,CAAC;IAChF,IAAI,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,gBAAgB,KAAK,kBAAkB,CAAC,CAAC;IAC5E,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type CellMark, type Marks } from "../core/tabular.js";
|
|
2
|
+
export type Grid = (string | null)[][];
|
|
3
|
+
export type MarkGrid = (CellMark | null)[][];
|
|
4
|
+
export type Link = {
|
|
5
|
+
file: string;
|
|
6
|
+
url: string;
|
|
7
|
+
text: string;
|
|
8
|
+
year: number | null;
|
|
9
|
+
};
|
|
10
|
+
/** Two-digit year of a file name ("23in11si.xls" -> 2023, "98in11si.xls" -> 1998), or null. */
|
|
11
|
+
export declare function fileYear(file: string): number | null;
|
|
12
|
+
/** The spreadsheet, zip and CSV links of an index page, in page order. */
|
|
13
|
+
export declare function pageLinks(html: string, page: string): Link[];
|
|
14
|
+
/** Sheets and cell marks of a downloaded table file (.xls, .xlsx, or a zip holding one). */
|
|
15
|
+
export declare function readWorkbook(body: Uint8Array, name: string): {
|
|
16
|
+
sheets: Record<string, Grid>;
|
|
17
|
+
marks: Marks;
|
|
18
|
+
order: string[];
|
|
19
|
+
};
|
|
20
|
+
export type SoiColumn = {
|
|
21
|
+
idx: number;
|
|
22
|
+
col: number | null;
|
|
23
|
+
name: string;
|
|
24
|
+
};
|
|
25
|
+
export type SoiCell = {
|
|
26
|
+
idx: number;
|
|
27
|
+
col: number | null;
|
|
28
|
+
name: string;
|
|
29
|
+
value: string;
|
|
30
|
+
flag: string;
|
|
31
|
+
};
|
|
32
|
+
export type SoiRow = {
|
|
33
|
+
line: number;
|
|
34
|
+
level: number;
|
|
35
|
+
section: string;
|
|
36
|
+
parent: string;
|
|
37
|
+
label: string;
|
|
38
|
+
cells: SoiCell[];
|
|
39
|
+
};
|
|
40
|
+
export type SoiTable = {
|
|
41
|
+
title: string;
|
|
42
|
+
headnote: string;
|
|
43
|
+
units: string;
|
|
44
|
+
header: number[];
|
|
45
|
+
numberRows: number[];
|
|
46
|
+
columns: SoiColumn[];
|
|
47
|
+
rows: SoiRow[];
|
|
48
|
+
footer: string[];
|
|
49
|
+
notes: string[];
|
|
50
|
+
};
|
|
51
|
+
/** Value and marker of one cell: "* 1,335" -> 1335 / "*"; "[2]" -> "" / "[2]"; "d" -> "" / "d". */
|
|
52
|
+
export declare function parseCell(raw: unknown, fmt?: string): {
|
|
53
|
+
value: string;
|
|
54
|
+
flag: string;
|
|
55
|
+
} | null;
|
|
56
|
+
/**
|
|
57
|
+
* Column names from stacked header lines (1-based): each column's cells joined top-down with " | ". A filled cell of a
|
|
58
|
+
* line spans to the right over blank cells while the line above stays the same (a group label over its columns, a
|
|
59
|
+
* merged cell written in its first column only); the last line never spans. Label columns take no part.
|
|
60
|
+
*/
|
|
61
|
+
export declare function headerNames(grid: Grid, lines: number[], width: number, labelCols: number[]): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Reads one sheet of an SOI table. A sheet can hold several blocks (the pages of a printed table, each with its own
|
|
64
|
+
* header and column numbers: 1998 Table 1.1 numbers columns 1-20 on page 1 and 21-40 on page 2); each block starts
|
|
65
|
+
* after the last data line of the one before. headerLines (1-based, from the catalog) replaces the layout reading of
|
|
66
|
+
* the header for a table without column numbers.
|
|
67
|
+
*/
|
|
68
|
+
export declare function readSoiGrid(grid0: Grid, marks: MarkGrid | undefined, headerLines?: number[]): SoiTable;
|
|
69
|
+
export type TableFilter = {
|
|
70
|
+
rows?: string[];
|
|
71
|
+
columns?: string[];
|
|
72
|
+
section?: string[];
|
|
73
|
+
};
|
|
74
|
+
/** Does a column match a `columns` filter item: a column number (7, "7", "(7)") or a header substring? */
|
|
75
|
+
export declare function columnHit(c: SoiColumn, want: string[]): boolean;
|
|
76
|
+
export type LongRow = Record<string, string | number>;
|
|
77
|
+
/** One row per cell (long): the identifiers, SECTION ... ROW_LABEL, then COL, COLUMN, VALUE, FLAG, UNITS. */
|
|
78
|
+
export declare function longRows(t: SoiTable, id: Record<string, string | number>, f: TableFilter): LongRow[];
|
|
79
|
+
/** One row per line (wide): the identifiers, SECTION ... ROW_LABEL, then one column per table column ("(n) name")
|
|
80
|
+
* and, where a cell carries a marker, "(n) name FLAG". */
|
|
81
|
+
export declare function wideRows(t: SoiTable, id: Record<string, string | number>, f: TableFilter): [LongRow[], string[]];
|
|
82
|
+
/** The meaning of the markers a table's footer defines, e.g. "d = not shown to avoid disclosure ...". */
|
|
83
|
+
export declare function markerNotes(t: SoiTable): string[];
|