首页 > 解决方案 > 如何读取在 AbInitio 中用双引号括起来的字段值中有分隔符的文件

问题描述

我有一个由竖线 (|) 分隔的 .dat 文件。现在我的专栏可以有 | 在数据中。我在阅读此文件并逐列加载时遇到问题。

使用的 DML:

record
string("|") col1,
string("|") col2,
string("|") col3,
string("|") col4,
end

源值:

"Col1"|"col2"|"col3"|"col4"
"units of the price | currency used" | "ABC" | "20210831" | ""

所以 col1 = 价格单位 | 使用的货币,col2 = ABC,col3 = 20210831,col4 = null

根据我的 dml,它打破了 2 中的第一个 col,因此失败了。如何读取文件并使用正确的值加载它。

标签: ab-initio

解决方案


您可以将分隔符定义为string(\"|"\")"|"用作分隔符而不是仅用作分隔符|- 您最终会在记录的开头和结尾处得到一个额外"的,但稍后很容易删除


推荐阅读