Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/format/stream/delimited-text-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ export function delimitedTextTransformer(delimiter = ',') {
if (++qc === 3) {
// consume escaped quote char ("")
qc = 1;
} else if (++I < N && chunk.charCodeAt(I) !== QUOTE) {
} else if ((I + 1) < N && chunk.charCodeAt(I + 1) !== QUOTE) {
qc = 0; // reset quote char count
q = true; // reached end of quote
++I;
break;
}
}
Expand Down Expand Up @@ -148,7 +149,9 @@ export function delimitedTextTransformer(delimiter = ',') {

flush(controller) {
if (row.length || fragment) {
if (fragment != null) row.push(fragment);
if (fragment != null) {
row.push(qc === 2 ? unquote(fragment) : fragment);
}
controller.enqueue([row]);
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/format/from-csv-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ function csvTests(name, parseCSV) {
const csvLoad = await parseCSV(csv);
assert.strictEqual(csvLoad.numRows(), numRows);
assert.strictEqual(csvLoad.numCols(), numCols);

// test embedded map
const map = '{"0"=>"https://web.site", "1"=>"https://other.site.com/"}';
const mapData = { id: [1, 2], map: [map, map] };
tableEqual(
await parseCSV(table(mapData).toCSV()),
mapData,
'csv parsed map data'
);
});
});
}