Skip to content

bug(portfolio-import): 欧洲 Excel 分号分隔 CSV 被整行当成单列 #408

Open
wannT-1/folio
#7

Description

@wannT-1

现象

欧洲区域 Excel「另存为 CSV」常用 分号 ; 作分隔符(小数点用逗号)。当前 csvDelimiter 只在未加引号时识别 , 或 \t,不识别 ;,于是整行被当成一个 cell。

证据(当前 main)

packages/shared/src/portfolio-import/parsers.ts:

function csvDelimiter(line: string): ',' | '\t' {
  let inQuotes = false
  for (const ch of line) {
    if (ch === '"') inQuotes = !inQuotes
    else if (!inQuotes && (ch === ',' || ch === '\t')) return ch
  }
  return ','
}

返回类型也不含 ';。

复现

Symbol;Quantity;Cost
AAPL.US;10;100.5
  • 实际:只有一列;symbol 可能变成整行字符串,quantity/cost 缺失并带 issues。
  • 预期:与逗号分隔的等价文件解析出相同的 symbol/quantity/cost。

建议修复(小范围)

  • csvDelimiter 在 , / \t 之外识别未加引号的 ;(优先级:文件中实际出现的第一个分隔符;若同时出现,按既有「第一个未加引号分隔符」语义即可)。
  • splitCsvLine / resolveCsvColumns 类型扩展到 ';。
  • 补 focused 回归:分号表头 + 数据行;以及带引号字段内含分号时不被切开。

范围

仅 delimiter 检测与切分。不引入欧洲千分位/小数点数字语义(那是独立议题)。与 #356–#360 无重叠。

查重

搜索 semicolon / 分号 / delimiter 相关 open issue 未见同类。

Activity

  1. wannT-1 commented on Oct 30, 2026

    @wannT-1
    Author

    /claim

    我来修分号分隔 CSV:扩展 csvDelimiter/splitCsvLine 识别 ;,补表头+数据行与引号内分号回归。提交 PR 时写 Closes #408。

  2. github-actions commented on Oct 30, 2026

    @github-actions

    @wannT-1 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #408。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimedClaimed by a contributor and currently in progress

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions