Skip to content

Commit

Permalink
use d3.autoType when parsing CSV data (#111)
Browse files Browse the repository at this point in the history
to get numbers and dates in the resulting JSON data array for Data Summary view
  • Loading branch information
RandomFractals committed Jan 28, 2022
1 parent a79bac2 commit a7dccd5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/renderer/outputLoader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {OutputItem} from 'vscode-notebook-renderer';
import {csvParse} from 'd3-dsv';
import type { OutputItem } from 'vscode-notebook-renderer';
import { csvParse, autoType } from 'd3-dsv';
const aq = require('arquero');
const xmlParser = require('fast-xml-parser');

Expand Down Expand Up @@ -50,7 +50,7 @@ export class OutputLoader {
}
else if (this.isCsv(textData)) {
// parse CSV data
return csvParse(textData);
return csvParse(textData, autoType);
}
else if (textData !== '{}' && !textData.startsWith('<Buffer ')) { // empty object or binary data
return textData;
Expand Down Expand Up @@ -118,7 +118,7 @@ export class OutputLoader {
if (this.isCsv(jsonData)) {
// parse CSV data for JSON response from REST Book
// see: https://github.com/tanhakabir/rest-book/issues/114
return csvParse(jsonData);
return csvParse(jsonData, autoType);
}
else if (jsonData.startsWith('<?xml version="1.0"')) {
// try to parse XML data as the last resort
Expand Down

0 comments on commit a7dccd5

Please sign in to comment.