MCPcopy Create free account
hub / github.com/Devographics/Monorepo / parseCSVFile

Function parseCSVFile

surveyadmin/src/scripts/loadTokyoDevCSV.ts:36–58  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

34};
35
36async function parseCSVFile<T>(filename: string): Promise<T[]> {
37 const rows: T[] = [];
38
39 await new Promise<void>((resolve, reject) => {
40 fs.createReadStream(filename)
41 .pipe(csvParser())
42 .on("data", (data: any) => {
43 const row = {} as T;
44 for (const [key, value] of Object.entries(data)) {
45 row[key] = value;
46 }
47 rows.push(row);
48 })
49 .on("end", () => {
50 resolve();
51 })
52 .on("error", (error: Error) => {
53 reject(error);
54 });
55 });
56
57 return rows;
58}
59
60const loadYamlFile = async (surveyId) => {
61 const contents = await readFile(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected