support semicolon-separated data when importing delimiter-separated values files / data (#458)
This commit is contained in:
@@ -29,6 +29,7 @@ import (
|
||||
var supportedFileTypeSeparators = map[string]rune{
|
||||
"custom_csv": ',',
|
||||
"custom_tsv": '\t',
|
||||
"custom_ssv": ';',
|
||||
}
|
||||
|
||||
var supportedFileEncodings = map[string]encoding.Encoding{
|
||||
|
||||
@@ -17,10 +17,12 @@ import (
|
||||
func TestIsDelimiterSeparatedValuesFileType(t *testing.T) {
|
||||
assert.True(t, IsDelimiterSeparatedValuesFileType("custom_csv"))
|
||||
assert.True(t, IsDelimiterSeparatedValuesFileType("custom_tsv"))
|
||||
assert.True(t, IsDelimiterSeparatedValuesFileType("custom_ssv"))
|
||||
|
||||
assert.False(t, IsDelimiterSeparatedValuesFileType("dsv"))
|
||||
assert.False(t, IsDelimiterSeparatedValuesFileType("csv"))
|
||||
assert.False(t, IsDelimiterSeparatedValuesFileType("tsv"))
|
||||
assert.False(t, IsDelimiterSeparatedValuesFileType("ssv"))
|
||||
}
|
||||
|
||||
func TestCustomTransactionDataDsvFileParser_ParseDsvFileLines(t *testing.T) {
|
||||
@@ -65,6 +67,26 @@ func TestCustomTransactionDataDsvFileParser_ParseDsvFileLines(t *testing.T) {
|
||||
assert.Equal(t, "2024-09-01 23:59:59", allLines[1][0])
|
||||
assert.Equal(t, "T", allLines[1][1])
|
||||
assert.Equal(t, "0.05", allLines[1][2])
|
||||
|
||||
importer, err = CreateNewCustomTransactionDataDsvFileParser("custom_ssv", "utf-8")
|
||||
assert.Nil(t, err)
|
||||
|
||||
allLines, err = importer.ParseDsvFileLines(context, []byte(
|
||||
"2024-09-01 12:34:56;E;1.00\n"+
|
||||
"2024-09-01 23:59:59;T;0.05"))
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, 2, len(allLines))
|
||||
|
||||
assert.Equal(t, 3, len(allLines[0]))
|
||||
assert.Equal(t, "2024-09-01 12:34:56", allLines[0][0])
|
||||
assert.Equal(t, "E", allLines[0][1])
|
||||
assert.Equal(t, "1.00", allLines[0][2])
|
||||
|
||||
assert.Equal(t, 3, len(allLines[1]))
|
||||
assert.Equal(t, "2024-09-01 23:59:59", allLines[1][0])
|
||||
assert.Equal(t, "T", allLines[1][1])
|
||||
assert.Equal(t, "0.05", allLines[1][2])
|
||||
}
|
||||
|
||||
func TestCustomTransactionDataDsvFileImporter_MinimumValidData(t *testing.T) {
|
||||
|
||||
@@ -141,6 +141,11 @@ export const SUPPORTED_IMPORT_FILE_CATEGORY_AND_TYPES: ImportFileCategoryAndType
|
||||
type: 'custom_tsv',
|
||||
name: 'TSV (Tab-separated values) File',
|
||||
extensions: '.tsv,.txt',
|
||||
},
|
||||
{
|
||||
type: 'custom_ssv',
|
||||
name: 'SSV (Semicolon-separated values) File',
|
||||
extensions: '.txt',
|
||||
}
|
||||
],
|
||||
supportedEncodings: SUPPORTED_FILE_ENCODINGS,
|
||||
@@ -163,6 +168,11 @@ export const SUPPORTED_IMPORT_FILE_CATEGORY_AND_TYPES: ImportFileCategoryAndType
|
||||
type: 'custom_tsv',
|
||||
name: 'TSV (Tab-separated values) File',
|
||||
extensions: '.tsv,.txt',
|
||||
},
|
||||
{
|
||||
type: 'custom_ssv',
|
||||
name: 'SSV (Semicolon-separated values) File',
|
||||
extensions: '.txt',
|
||||
}
|
||||
],
|
||||
dataFromTextbox: true,
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "CSV (Kommagetrennte Werte) Datei",
|
||||
"TSV (Tab-separated values) File": "TSV (Tabulatorgetrennte Werte) Datei",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "CSV (Comma-separated values) File",
|
||||
"TSV (Tab-separated values) File": "TSV (Tab-separated values) File",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "Formato de Archivo",
|
||||
"CSV (Comma-separated values) File": "Archivo CSV (valores separados por comas)",
|
||||
"TSV (Tab-separated values) File": "Archivo TSV (valores separados por tabulaciones)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Exportar a archivo CSV (Valores Separados por Comas)",
|
||||
"Export to TSV (Tab-separated values) File": "Exportar a archivo TSV (Valores Separados por Tabulaciones)",
|
||||
"Markdown File": "Archivo Markdown",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "Format de fichier",
|
||||
"CSV (Comma-separated values) File": "Fichier CSV (valeurs séparées par virgules)",
|
||||
"TSV (Tab-separated values) File": "Fichier TSV (valeurs séparées par tabulations)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Exporter vers un fichier CSV (valeurs séparées par virgules)",
|
||||
"Export to TSV (Tab-separated values) File": "Exporter vers un fichier TSV (valeurs séparées par tabulations)",
|
||||
"Markdown File": "Fichier Markdown",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "File CSV (valori separati da virgola)",
|
||||
"TSV (Tab-separated values) File": "File TSV (valori separati da tabulazione)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "CSV(コンマ区切り)ファイル",
|
||||
"TSV (Tab-separated values) File": "TSV(タブ区切り)ファイル",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "ಫೈಲ್ ಫಾರ್ಮ್ಯಾಟ್",
|
||||
"CSV (Comma-separated values) File": "CSV (ಕಾಮಾ-ಪ್ರತ್ಯೇಕಿತ ಮೌಲ್ಯಗಳು) ಫೈಲ್",
|
||||
"TSV (Tab-separated values) File": "TSV (ಟ್ಯಾಬ್-ಪ್ರತ್ಯೇಕಿತ ಮೌಲ್ಯಗಳು) ಫೈಲ್",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "CSV (ಕಾಮಾ-ಪ್ರತ್ಯೇಕಿತ ಮೌಲ್ಯಗಳು) ಫೈಲ್ಗೆ ರಫ್ತು ಮಾಡಿ",
|
||||
"Export to TSV (Tab-separated values) File": "TSV (ಟ್ಯಾಬ್-ಪ್ರತ್ಯೇಕಿತ ಮೌಲ್ಯಗಳು) ಫೈಲ್ಗೆ ರಫ್ತು ಮಾಡಿ",
|
||||
"Markdown File": "Markdown ಫೈಲ್",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "파일 형식",
|
||||
"CSV (Comma-separated values) File": "CSV (쉼표로 구분된 값) 파일",
|
||||
"TSV (Tab-separated values) File": "TSV (탭으로 구분된 값) 파일",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "CSV (쉼표로 구분된 값) 파일로 내보내기",
|
||||
"Export to TSV (Tab-separated values) File": "TSV (탭으로 구분된 값) 파일로 내보내기",
|
||||
"Markdown File": "Markdown 파일",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "Bestandsformaat",
|
||||
"CSV (Comma-separated values) File": "CSV-bestand (komma-gescheiden waarden)",
|
||||
"TSV (Tab-separated values) File": "TSV-bestand (tab-gescheiden waarden)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Exporteren naar CSV-bestand (komma-gescheiden waarden)",
|
||||
"Export to TSV (Tab-separated values) File": "Exporteren naar TSV-bestand (tab-gescheiden waarden)",
|
||||
"Markdown File": "Markdown-bestand",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "Formato de Arquivo",
|
||||
"CSV (Comma-separated values) File": "Arquivo CSV (Valores separados por vírgulas)",
|
||||
"TSV (Tab-separated values) File": "Arquivo TSV (Valores separados por tabulações)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Arquivo Markdown",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "Файл CSV (значения, разделенные запятыми)",
|
||||
"TSV (Tab-separated values) File": "Файл TSV (значения, разделенные табуляцией)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "Format datoteke",
|
||||
"CSV (Comma-separated values) File": "CSV datoteka",
|
||||
"TSV (Tab-separated values) File": "TSV datoteka",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Izvozi v CSV datoteko",
|
||||
"Export to TSV (Tab-separated values) File": "Izvozi v TSV datoteko",
|
||||
"Markdown File": "Markdown datoteka",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "கோப்பு வடிவம்",
|
||||
"CSV (Comma-separated values) File": "CSV (காற்புள்ளி-தனிப்பட்ட மதிப்புகள்) கோப்பு",
|
||||
"TSV (Tab-separated values) File": "TSV (தாவல்-தனிப்பட்ட மதிப்புகள்) கோப்பு",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "CSV (காற்புள்ளி-தனிப்பட்ட மதிப்புகள்) கோப்புக்கு ஏற்றுமதி செய்",
|
||||
"Export to TSV (Tab-separated values) File": "TSV (தாவல்-தனிப்பட்ட மதிப்புகள்) கோப்புக்கு ஏற்றுமதி செய்",
|
||||
"Markdown File": "Markdown கோப்பு",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "รูปแบบไฟล์",
|
||||
"CSV (Comma-separated values) File": "ไฟล์ CSV (คั่นด้วยเครื่องหมายจุลภาค)",
|
||||
"TSV (Tab-separated values) File": "ไฟล์ TSV (คั่นด้วยแท็บ)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "ส่งออกเป็นไฟล์ CSV (คั่นด้วยเครื่องหมายจุลภาค)",
|
||||
"Export to TSV (Tab-separated values) File": "ส่งออกเป็นไฟล์ TSV (คั่นด้วยแท็บ)",
|
||||
"Markdown File": "ไฟล์ Markdown",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "Dosya Formatı",
|
||||
"CSV (Comma-separated values) File": "CSV (Virgülle ayrılmış değerler) Dosyası",
|
||||
"TSV (Tab-separated values) File": "TSV (Sekmeyle ayrılmış değerler) Dosyası",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "CSV (Virgülle ayrılmış değerler) Dosyasına Dışa Aktar",
|
||||
"Export to TSV (Tab-separated values) File": "TSV (Sekmeyle ayrılmış değerler) Dosyasına Dışa Aktar",
|
||||
"Markdown File": "Markdown Dosyası",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "Файл CSV (значення, розділені комами)",
|
||||
"TSV (Tab-separated values) File": "Файл TSV (значення, розділені табуляцією)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "File Format",
|
||||
"CSV (Comma-separated values) File": "Tệp CSV (Giá trị phân cách bằng dấu phẩy)",
|
||||
"TSV (Tab-separated values) File": "Tệp TSV (Giá trị phân cách bằng tab)",
|
||||
"SSV (Semicolon-separated values) File": "SSV (Semicolon-separated values) File",
|
||||
"Export to CSV (Comma-separated values) File": "Export to CSV (Comma-separated values) File",
|
||||
"Export to TSV (Tab-separated values) File": "Export to TSV (Tab-separated values) File",
|
||||
"Markdown File": "Markdown File",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "文件格式",
|
||||
"CSV (Comma-separated values) File": "CSV (逗号分隔的值) 文件",
|
||||
"TSV (Tab-separated values) File": "TSV (制表符分隔的值) 文件",
|
||||
"SSV (Semicolon-separated values) File": "SSV (分号分隔的值) 文件",
|
||||
"Export to CSV (Comma-separated values) File": "导出到 CSV (逗号分隔的值) 文件",
|
||||
"Export to TSV (Tab-separated values) File": "导出到 TSV (制表符分隔的值) 文件",
|
||||
"Markdown File": "Markdown 文件",
|
||||
|
||||
@@ -2292,6 +2292,7 @@
|
||||
"File Format": "檔案格式",
|
||||
"CSV (Comma-separated values) File": "CSV (逗號分隔的值) 檔案",
|
||||
"TSV (Tab-separated values) File": "TSV (定位點分隔的值) 檔案",
|
||||
"SSV (Semicolon-separated values) File": "SSV (分號分隔的值) 檔案",
|
||||
"Export to CSV (Comma-separated values) File": "匯出為 CSV (逗號分隔的值) 檔案",
|
||||
"Export to TSV (Tab-separated values) File": "匯出為 TSV (定位點分隔的值) 檔案",
|
||||
"Markdown File": "Markdown 檔案",
|
||||
|
||||
@@ -715,6 +715,8 @@ function parseData(): void {
|
||||
uploadFile = KnownFileType.CSV.createFile(importData.value, 'import');
|
||||
} else if (type === 'custom_tsv') {
|
||||
uploadFile = KnownFileType.TSV.createFile(importData.value, 'import');
|
||||
} else if (type === 'custom_ssv') {
|
||||
uploadFile = KnownFileType.TXT.createFile(importData.value, 'import');
|
||||
} else {
|
||||
snackbar.value?.showError('Parameter Invalid');
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user