Skip to content

Commit

Permalink
Add support for quotes in CSV parser tool
Browse files Browse the repository at this point in the history
  • Loading branch information
255kb committed Nov 18, 2024
1 parent d5f9990 commit b00910c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/tools/csv-parser-json-converter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ Alice,35,Chicago,Data Scientist,Amazon,Seattle,345-678-9012`;
}

if (index === 0) {
headers = line.split(',');
headers = line
.split(',')
.map((item) => item.trim().replace(/^"(.*)"$/, '$1'));

return;
} else {
const items = line.split(',');
const items = line
.split(',')
.map((item) => item.trim().replace(/^"(.*)"$/, '$1'));

lines.push(items);
}
Expand Down

0 comments on commit b00910c

Please sign in to comment.