mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-10 16:26:43 -05:00
fix: csv parser delimiter (#1774)
This commit is contained in:
@@ -578,7 +578,7 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
// options which are simple post-processing. That means if you
|
||||
// parsed different files without closing the modal, it wouldn't
|
||||
// re-read this.
|
||||
let [csvDelimiter, setCsvDelimiter] = useState(
|
||||
let [delimiter, setDelimiter] = useState(
|
||||
prefs[`csv-delimiter-${accountId}`] ||
|
||||
(filename.endsWith('.tsv') ? '\t' : ','),
|
||||
);
|
||||
@@ -666,7 +666,7 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
const fileType = getFileType(options.filename);
|
||||
const parseOptions = getParseOptions(
|
||||
fileType,
|
||||
{ csvDelimiter, hasHeaderRow },
|
||||
{ delimiter, hasHeaderRow },
|
||||
{ fallbackMissingPayeeToMemo },
|
||||
);
|
||||
|
||||
@@ -716,7 +716,7 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
const fileType = getFileType(res[0]);
|
||||
const parseOptions = getParseOptions(
|
||||
fileType,
|
||||
{ csvDelimiter, hasHeaderRow },
|
||||
{ delimiter, hasHeaderRow },
|
||||
{ fallbackMissingPayeeToMemo },
|
||||
);
|
||||
|
||||
@@ -787,7 +787,7 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
savePrefs({
|
||||
[`csv-mappings-${accountId}`]: JSON.stringify(fieldMappings),
|
||||
});
|
||||
savePrefs({ [`csv-delimiter-${accountId}`]: csvDelimiter });
|
||||
savePrefs({ [`csv-delimiter-${accountId}`]: delimiter });
|
||||
}
|
||||
|
||||
if (filetype === 'csv' || filetype === 'qif') {
|
||||
@@ -966,11 +966,12 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
options={[
|
||||
[',', ','],
|
||||
[';', ';'],
|
||||
['|', '|'],
|
||||
['\t', 'tab'],
|
||||
]}
|
||||
value={csvDelimiter}
|
||||
value={delimiter}
|
||||
onChange={value => {
|
||||
setCsvDelimiter(value);
|
||||
setDelimiter(value);
|
||||
parse(
|
||||
filename,
|
||||
getParseOptions('csv', {
|
||||
@@ -990,7 +991,7 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
parse(
|
||||
filename,
|
||||
getParseOptions('csv', {
|
||||
delimiter: csvDelimiter,
|
||||
delimiter,
|
||||
hasHeaderRow: !hasHeaderRow,
|
||||
}),
|
||||
);
|
||||
@@ -1070,8 +1071,8 @@ export default function ImportTransactions({ modalProps, options }) {
|
||||
|
||||
function getParseOptions(fileType, csvOptions, ofxOptions) {
|
||||
if (fileType === 'csv') {
|
||||
const { csvDelimiter, hasHeaderRow } = csvOptions;
|
||||
return { csvDelimiter, hasHeaderRow };
|
||||
const { delimiter, hasHeaderRow } = csvOptions;
|
||||
return { delimiter, hasHeaderRow };
|
||||
} else if (isOfxFile(fileType)) {
|
||||
const { fallbackMissingPayeeToMemo } = ofxOptions;
|
||||
return { fallbackMissingPayeeToMemo };
|
||||
|
||||
6
upcoming-release-notes/1774.md
Normal file
6
upcoming-release-notes/1774.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [KaiBelmo]
|
||||
---
|
||||
|
||||
Fix selecting delimiters in CSV options when uploading a CSV; it will apply to parsing. Also added a new delimiter '|'.
|
||||
Reference in New Issue
Block a user