From 1796b519e57b009235e8888581f6fbba0943205c Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Thu, 9 Jul 2020 15:01:48 -0700 Subject: [PATCH] Fixed a Bug where csv is treated as txt file by import wizard (#11271) * Add CodeQL Analysis workflow (#10195) * Add CodeQL Analysis workflow * Fix path * Fixed the bug where CSVs were treated as TXT files Co-authored-by: Justin Hutchings --- .../import/src/wizard/pages/fileConfigPage.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/extensions/import/src/wizard/pages/fileConfigPage.ts b/extensions/import/src/wizard/pages/fileConfigPage.ts index 298d276a7f..11fb379166 100644 --- a/extensions/import/src/wizard/pages/fileConfigPage.ts +++ b/extensions/import/src/wizard/pages/fileConfigPage.ts @@ -201,11 +201,24 @@ export class FileConfigPage extends ImportPage { if (nameEnd === 0) { nameEnd = fileUri.path.length; } - this.model.fileType = 'TXT'; + let extension = fileUri.path.substring(nameEnd + 1, fileUri.path.length); - if (extension.toLowerCase() === 'json') { - this.model.fileType = 'JSON'; + /** + * FileType should be TXT for txt files and files with unknown types. + * CSVs and TSVs are treated as the CSV file while learning in the prose library. + */ + + switch (extension.toLowerCase()) { + case 'json': + this.model.fileType = 'JSON'; + break; + case 'csv': + case 'tsv': + this.model.fileType = 'CSV'; + break; + default: + this.model.fileType = 'TXT'; } this.tableNameTextBox.value = fileUri.path.substring(nameStart + 1, nameEnd);