ab-initio - 如何读取在 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,因此失败了。如何读取文件并使用正确的值加载它。
解决方案
您可以将分隔符定义为string(\"|"\")
即"|"
用作分隔符而不是仅用作分隔符|
- 您最终会在记录的开头和结尾处得到一个额外"
的,但稍后很容易删除
推荐阅读
- javascript - 在js中按值获取字典排名
- javascript - 如何使用 Javascript 隐藏和显示基于某个 div 类库的多个 div?
- html - 如何创建旁边有表格的英雄图像并制作全角?
- parsing - 在 LR(1) 前瞻中考虑了哪些产生式?
- jquery - css()的三种使用方式
- c - 如何让 C 查看文件并找到某个字符串?
- node.js - 将 React/Node 应用程序推送到 Heroku 时不断收到“找不到模块”错误
- spring-boot - 仅将 PreAuthorize 应用于第一个服务方法
- php - 检查表中是否存在特定的ID,显示空或null而不是显示No records found
- ruby-on-rails - 如何在 Rails 中建模这些关系