mirror of
https://github.com/iib0011/omni-tools.git
synced 2026-12-01 09:22:25 +03:00
fix: edge case (empty string in csv-rows-to-columns)
This commit is contained in:
1 parent
0da754c0e9
commit
9f13da2968
1 file changed
+11
-5
@@ -17,12 +17,18 @@ export function csvRowsToColumns(
|
||||
customFiller: string,
|
||||
commentCharacter: string
|
||||
): string {
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const rows = input
|
||||
.split('\n')
|
||||
.map((row) => row.split(','))
|
||||
.filter(
|
||||
(row) => row.length > 0 && !row[0].trim().startsWith(commentCharacter)
|
||||
);
|
||||
? input
|
||||
.split('\n')
|
||||
.map((row) => row.split(','))
|
||||
.filter(
|
||||
(row) => row.length > 0 && !row[0].trim().startsWith(commentCharacter)
|
||||
)
|
||||
: [];
|
||||
const columnCount = Math.max(...rows.map((row) => row.length));
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
for (let j = 0; j < columnCount; j++) {
|
||||
|
||||
Reference in new issue
Block a user