MCPcopy Create free account
hub / github.com/DFin/palaeograph / parseCSV

Function parseCSV

src/csvLoader.js:49–78  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

47}
48
49export async function parseCSV(file) {
50 return new Promise((resolve, reject) => {
51 Papa.parse(file, {
52 header: true,
53 skipEmptyLines: true,
54 dynamicTyping: false,
55 complete(results) {
56 const headers = (results.meta.fields || []).map(sanitizeHeader).filter(Boolean);
57 const rows = results.data
58 .map((entry) => {
59 const row = {};
60 headers.forEach((header) => {
61 row[header] = entry[header];
62 });
63 return row;
64 })
65 .filter((row) => Object.values(row).some((value) => value !== null && value !== ""));
66
67 resolve({
68 headers,
69 rows,
70 columnStats: analyzeColumns(rows, headers)
71 });
72 },
73 error(error) {
74 reject(error);
75 }
76 });
77 });
78}
79
80export function buildNumericColumnList(columnStats) {
81 return columnStats.filter((column) => column.isNumeric).map((column) => column.name);

Callers 1

handleFileListFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected