Files
trezor-suite/suite/e2e/support/csvToJson.ts
2025-12-05 04:33:08 -04:00

17 lines
450 B
TypeScript

export const csvToJson = (data: string) => {
const lines = data.split('\n');
const result = [];
const headers = lines[0].split(',');
for (let i = 1; i < lines.length; i++) {
const obj: Record<string, string> = {};
const currentline = lines[i].split(',');
for (let j = 0; j < headers.length; j++) {
obj[headers[j]] = currentline[j];
}
result.push(obj);
}
return result;
};