(line: string)
| 96 | |
| 97 | |
| 98 | function parseCsvRow(line: string): string[] { |
| 99 | const cells: string[] = []; |
| 100 | let current = ''; |
| 101 | let inQuotes = false; |
| 102 | let i = 0; |
| 103 | while (i < line.length) { |
| 104 | const ch = line[i]; |
| 105 | if (inQuotes) { |
| 106 | if (ch === '"') { |
| 107 | if (line[i + 1] === '"') { |
| 108 | current += '"'; |
| 109 | i += 2; |
| 110 | continue; |
| 111 | } |
| 112 | inQuotes = false; |
| 113 | i += 1; |
| 114 | continue; |
| 115 | } |
| 116 | current += ch; |
| 117 | i += 1; |
| 118 | } else { |
| 119 | if (ch === '"') { |
| 120 | inQuotes = true; |
| 121 | i += 1; |
| 122 | continue; |
| 123 | } |
| 124 | if (ch === ',') { |
| 125 | cells.push(current); |
| 126 | current = ''; |
| 127 | i += 1; |
| 128 | continue; |
| 129 | } |
| 130 | current += ch; |
| 131 | i += 1; |
| 132 | } |
| 133 | } |
| 134 | cells.push(current); |
| 135 | return cells; |
| 136 | } |
no test coverage detected