mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-03-05 15:05:23 +01:00
17 lines
450 B
TypeScript
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;
|
|
};
|