Auto-detect tab-delimited CSV files with manual delimiter override#818
Auto-detect tab-delimited CSV files with manual delimiter override#818
Conversation
Agent-Logs-Url: https://github.com/microsoft/SandDance/sessions/a48a5e1c-2717-40cd-b665-024693b751a1 Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
|
@copilot maybe we should add a ui step on the upload dialog, both before and after we get the file? Actually - if this is vscode extension and the user didnt explicitly upload, where would the ui go... |
Agent-Logs-Url: https://github.com/microsoft/SandDance/sessions/2c5b6167-e21b-4fdb-8d7b-9e36d2af61c1 Co-authored-by: danmarshall <11507384+danmarshall@users.noreply.github.com>
Added a Delimiter dropdown to the Data browser sidebar tab (commit Implementation details:
|
Tab-delimited files with a
.csvextension are parsed as comma-separated, resulting in all data appearing as a single column. Since the file type is derived purely from the extension, there's no way for users to override the delimiter.Changes
packages/sanddance-explorer/src/dataLoader.ts: AddedguessDelimiterType(text, type)that inspects the first line of acsv-typed file and returnstsvif tabs outnumber commas. The detected type is forwarded to bothvega.read()andloadDataArray(). Respects anoTypeGuessflag to honour explicit user choices./\r?\n/split to handle CRLF (Windows) line endings"Last, First")csvtypecsvtypes pass through unchangedDataContent.typeto communicate the actual parsed type back to callers without mutating the inputpackages/sanddance-explorer/src/interfaces.ts: AddednoTypeGuess?: booleantoDataFile(bypasses auto-detection when the user explicitly picks a delimiter) andtype?: DataFileTypetoDataContent(carries the actual parsed type back to the caller).packages/sanddance-explorer/src/dialogs/dataBrowser.tsx: Added a Delimiter dropdown to the Data browser sidebar tab. It is shown only when the loaded file is CSV or TSV, and lets users switch between "Comma (,)" and "Tab" at any time — including in the VSCode extension where there is no file upload dialog. Selecting a different option immediately re-parses the data.packages/sanddance-explorer/src/language.ts: AddedlabelDelimiter,labelDelimiterComma, andlabelDelimiterTabstrings.packages/sanddance-explorer/src/explorer.tsx: AppliesdataContent.typeback to thedataFilestored in state (so the dropdown reflects the auto-detected delimiter), and wiresdataFileand anonReloadFileTypehandler intoDataBrowser. The handler reloads withnoTypeGuess: trueso the user's explicit choice is preserved on subsequent loads.