fix: added column separator select (comma, semicolon and both) in CSV viewer (#5604)

Co-authored-by: Henrique Dias <mail@hacdias.com>
This commit is contained in:
Ariel Leyva
2025-12-06 05:08:50 -05:00
committed by GitHub
parent f029c3005e
commit 204a3f0eea
3 changed files with 64 additions and 7 deletions

View File

@@ -7,7 +7,10 @@ export interface CsvData {
* Parse CSV content into headers and rows
* Supports quoted fields and handles commas within quotes
*/
export function parseCSV(content: string): CsvData {
export function parseCSV(
content: string,
columnSeparator: Array<string>
): CsvData {
if (!content || content.trim().length === 0) {
return { headers: [], rows: [] };
}
@@ -35,7 +38,7 @@ export function parseCSV(content: string): CsvData {
// Toggle quote state
inQuotes = !inQuotes;
}
} else if (char === "," && !inQuotes) {
} else if (columnSeparator.includes(char) && !inQuotes) {
// Field separator
row.push(currentField);
currentField = "";