mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-23 07:59:31 +02:00
feat: swap-csv-columns fixed
This commit is contained in:
@@ -13,7 +13,7 @@ export function splitCsv(
|
||||
let rows = input.split('\n').map((row) => row.split(','));
|
||||
|
||||
// Remove comments if deleteComment is true
|
||||
if (deleteComment) {
|
||||
if (deleteComment && commentCharacter) {
|
||||
rows = rows.filter((row) => !row[0].trim().startsWith(commentCharacter));
|
||||
}
|
||||
|
||||
@@ -24,3 +24,13 @@ export function splitCsv(
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the headers from a CSV string .
|
||||
* @param {string} input - The CSV input string.
|
||||
* @returns {string[]} - The CSV header as a 1D array.
|
||||
*/
|
||||
export function getCsvHeaders(csvString: string): string[] {
|
||||
const rows = csvString.split('\n').map((row) => row.split(','));
|
||||
return rows.length > 0 ? rows[0].map((header) => header.trim()) : [];
|
||||
}
|
||||
|
Reference in New Issue
Block a user