Escape char和Text Enclosure的用法

时间:2017-04-20 06:44:20

标签: talend talend-mdm

在tFileOutputDelimited组件中使用Escape char和Text Enclosure有什么用?我们如何使用它们?

enter image description here

提前致谢...

1 个答案:

答案 0 :(得分:2)

要回答您的问题,请考虑CSV文件中的以下示例

doubleValue()

我创建了一个简单的工作,如下面的

enter image description here

在上面的示例中,字符逗号bookId,bookname,description,authorname 1,Grammer,book that has details about grammer,author1 2,Special Characters, book that describes about some escape characters like \", punctuations and special characters ,etc.,author2 3,Mathematics, book that has mathematical operations like addition +, subtraction -, multiplication *, division / etc, author3 是分隔符。但是数据之间有一些逗号

写入CSV文件的数据如下所示,

enter image description here

现在当我从该文件中读取数据时,我将获得以下数据

","

如果您注意到, .------+------------------+-------------------------------------------------------+-------------------------------------. | tLogRow_3 | |=-----+------------------+-------------------------------------------------------+------------------------------------=| |bookId|bookName |description |author | |=-----+------------------+-------------------------------------------------------+------------------------------------=| |1 |Grammer |book that has details about grammer |author1 | |2 |Special Characters|book that describes about some escape characters like "| punctuations and special characters | |3 |Mathematics |book that has mathematical operations like addition + | subtraction - | '------+------------------+-------------------------------------------------------+-------------------------------------' 的日志中缺少某些数据。

这是因为数据之间的逗号。为避免使用"author"选项。此外,数据中有转义字符,即 Text Enclosure 。在文件中,它将打印为 \" 。如果"的值为 Text Enclosure ,则您需要转义数据中存在的字符 """ 。为此,您必须使用"选项,如下所示

enter image description here

现在我得到的输出是

enter image description here

当我读取这些数据时,我会得到如下数据,

Escape char

如果您发现,没有数据丢失

希望这会帮助你。