Add support for CSV file encoding

This commit is contained in:
2025-04-01 20:34:56 +02:00
parent 58b2d2c629
commit a0c6d28157
3 changed files with 3 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ in
profiles = { profiles = {
my-bank = { my-bank = {
parser = "pl.ing"; parser = "pl.ing";
encoding = "utf8";
}; };
}; };

View File

@@ -51,7 +51,7 @@ export function loadTransactions(file: string, profile: string, server: string,
.catch(x => console.error(x)) .catch(x => console.error(x))
fs.createReadStream(file) fs.createReadStream(file)
.pipe(iconv.decodeStream("win1250")) .pipe(iconv.decodeStream(profileConfig.encoding ?? "utf8"))
.pipe(Papa.parse(Papa.NODE_STREAM_INPUT)) .pipe(Papa.parse(Papa.NODE_STREAM_INPUT))
.on('data', handleRow) .on('data', handleRow)
.on('close', handleClose); .on('close', handleClose);

View File

@@ -8,6 +8,7 @@ export type Config = {
export type ProfileConfig = { export type ProfileConfig = {
parser: string; parser: string;
encoding?: string;
config?: ParserConfig; config?: ParserConfig;
}; };