Kettle - 以逗号作为小数点读取 CSV
Kettle - Read CSV with comma as decimal mark
我对 Pentaho 数据集成(又名 Kettle)进行了转换,我做的第一件事是使用 "CSV Input" 映射我的平面文件。
我在 windows 上的这一步从来没有遇到过问题,但现在我正在将 spoon 要去 运行 的服务器切换到 linux 服务器,现在我解析时遇到问题(将字符串转换为整数)。
转换的作用,简而言之,是这样的:
CSV 输入: 用于映射我的 CSV 中的所有字段。我使用 ISO-8859-1 编码。
过滤行:用于获取一些特定的行。
脚本 Values/Mod: 用于更改某些字段的某些值。
现在,导致问题的步骤:
Select / 重命名值: 用于将 header 重命名为我的 table 列,以便我可以将数据插入我的table。每个选项卡上有什么?
Select & 更改(选项卡)*省略空字段
字段名重命名为
Código codigo_cliente
Meta-data(制表符)*省略空字段
字段名重命名为 类型 二进制到正常 数据格式是否宽松? 宽容号码转换?
Código codigo_cliente 整数 N N N
我得到的错误是:
2015/06/03 09:49:10 - Select values.0 - ERROR (version 5.3.0.0-213, build 1 from 2015-02-02_12-17-08 by buildguy) : Unexpected error
2015/06/03 09:49:10 - Select values.0 - ERROR (version 5.3.0.0-213, build 1 from 2015-02-02_12-17-08 by buildguy) : org.pentaho.di.core.exception.KettleValueException:
2015/06/03 09:49:10 - Select values.0 - Unexpected conversion error while converting value [codigo_cliente String<binary-string>] to an Integer
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to Integer
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to number : non-numeric character found at position 7 for value [21.237,00]
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.getInteger(ValueMetaBase.java:1780)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.convertData(ValueMetaBase.java:3537)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.trans.steps.selectvalues.SelectValues.metadataValues(SelectValues.java:326)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.trans.steps.selectvalues.SelectValues.processRow(SelectValues.java:375)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2015/06/03 09:49:10 - Select values.0 - at java.lang.Thread.run(Thread.java:744)
2015/06/03 09:49:10 - Select values.0 - Caused by: org.pentaho.di.core.exception.KettleValueException:
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to Integer
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to number : non-numeric character found at position 7 for value [21.237,00]
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.convertStringToInteger(ValueMetaBase.java:1036)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.getInteger(ValueMetaBase.java:1720)
2015/06/03 09:49:10 - Select values.0 - ... 5 more
2015/06/03 09:49:10 - Select values.0 - Caused by: org.pentaho.di.core.exception.KettleValueException:
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to number : non-numeric character found at position 7 for value [21.237,00]
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.convertStringToInteger(ValueMetaBase.java:1028)
2015/06/03 09:49:10 - Select values.0 - ... 6 more
出现这个问题是因为,在此字段中,我在 CSV 文件中使用逗号作为小数点。
这是我的 CSV 文件的样子:
我的 CSV 文件 header:
Ano;Mês;Diretoria;Tipo;Tipo de macrorubrica;Macrorubrica;Conta contábil;Código;Cliente;OS;Descrição;Fornecedor;Documento;Tipo documento;Nota;Atividade;Tipo atividade;Descrição;UA;Valor;Orçado
其中一行:
2015;4;CERT;Custo Apropriado;CUSTO SERVIÇO PRESTADO;PESSOAL;14520 .201;87.979,00;SOF HAR;00077864;SQ 36525;FUNDACAO ABCD;1383;FP;;1048;.;.;2030;1.076,35;,00
如果更容易看的话,我的列 "Código" 的值(稍后将在 Select 值步骤中变为 "codigo_cliente")在这一行中是 87.979,00
在不更改我的 CSV 文件的情况下解决此问题的最佳方法是什么?
我找到了 the answer to it in two forums。我必须在我的 Select 值步骤中设置一些字段,这样它才能理解我的格式:
格式十进制分组 
#,###.##, 。
如果有人能想到更好的东西,请在这里分享:-)
根据@LeonardoSibela 的建议和自我回答,问题出在格式上。
理想情况下,两台机器之间除了某些特定于 JVM 的行为(例如 class 加载)外,不应有显着差异。
那到底有什么不同呢?系统的区域设置。
例如,如果您的 Linux 服务器设置为知道 #,###.##
的区域设置,但数据根于具有知道 #.###,##
的区域设置的系统,您有一个 (可解)问题。
正如您在自己的回答中提到的,您必须让流程知道提供数据的格式。
即:
- 格式:
#.###,##
- 十进制:
,
- 分组:
.
我对 Pentaho 数据集成(又名 Kettle)进行了转换,我做的第一件事是使用 "CSV Input" 映射我的平面文件。
我在 windows 上的这一步从来没有遇到过问题,但现在我正在将 spoon 要去 运行 的服务器切换到 linux 服务器,现在我解析时遇到问题(将字符串转换为整数)。
转换的作用,简而言之,是这样的:
CSV 输入: 用于映射我的 CSV 中的所有字段。我使用 ISO-8859-1 编码。
过滤行:用于获取一些特定的行。
脚本 Values/Mod: 用于更改某些字段的某些值。
现在,导致问题的步骤:
Select / 重命名值: 用于将 header 重命名为我的 table 列,以便我可以将数据插入我的table。每个选项卡上有什么?
Select & 更改(选项卡)*省略空字段
字段名重命名为
Código codigo_cliente
Meta-data(制表符)*省略空字段
字段名重命名为 类型 二进制到正常 数据格式是否宽松? 宽容号码转换?
Código codigo_cliente 整数 N N N
我得到的错误是:
2015/06/03 09:49:10 - Select values.0 - ERROR (version 5.3.0.0-213, build 1 from 2015-02-02_12-17-08 by buildguy) : Unexpected error
2015/06/03 09:49:10 - Select values.0 - ERROR (version 5.3.0.0-213, build 1 from 2015-02-02_12-17-08 by buildguy) : org.pentaho.di.core.exception.KettleValueException:
2015/06/03 09:49:10 - Select values.0 - Unexpected conversion error while converting value [codigo_cliente String<binary-string>] to an Integer
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to Integer
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to number : non-numeric character found at position 7 for value [21.237,00]
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.getInteger(ValueMetaBase.java:1780)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.convertData(ValueMetaBase.java:3537)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.trans.steps.selectvalues.SelectValues.metadataValues(SelectValues.java:326)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.trans.steps.selectvalues.SelectValues.processRow(SelectValues.java:375)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2015/06/03 09:49:10 - Select values.0 - at java.lang.Thread.run(Thread.java:744)
2015/06/03 09:49:10 - Select values.0 - Caused by: org.pentaho.di.core.exception.KettleValueException:
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to Integer
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to number : non-numeric character found at position 7 for value [21.237,00]
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.convertStringToInteger(ValueMetaBase.java:1036)
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.getInteger(ValueMetaBase.java:1720)
2015/06/03 09:49:10 - Select values.0 - ... 5 more
2015/06/03 09:49:10 - Select values.0 - Caused by: org.pentaho.di.core.exception.KettleValueException:
2015/06/03 09:49:10 - Select values.0 - codigo_cliente String<binary-string> : couldn't convert String to number : non-numeric character found at position 7 for value [21.237,00]
2015/06/03 09:49:10 - Select values.0 -
2015/06/03 09:49:10 - Select values.0 - at org.pentaho.di.core.row.value.ValueMetaBase.convertStringToInteger(ValueMetaBase.java:1028)
2015/06/03 09:49:10 - Select values.0 - ... 6 more
出现这个问题是因为,在此字段中,我在 CSV 文件中使用逗号作为小数点。
这是我的 CSV 文件的样子:
我的 CSV 文件 header:
Ano;Mês;Diretoria;Tipo;Tipo de macrorubrica;Macrorubrica;Conta contábil;Código;Cliente;OS;Descrição;Fornecedor;Documento;Tipo documento;Nota;Atividade;Tipo atividade;Descrição;UA;Valor;Orçado
其中一行:
2015;4;CERT;Custo Apropriado;CUSTO SERVIÇO PRESTADO;PESSOAL;14520 .201;87.979,00;SOF HAR;00077864;SQ 36525;FUNDACAO ABCD;1383;FP;;1048;.;.;2030;1.076,35;,00
如果更容易看的话,我的列 "Código" 的值(稍后将在 Select 值步骤中变为 "codigo_cliente")在这一行中是 87.979,00
在不更改我的 CSV 文件的情况下解决此问题的最佳方法是什么?
我找到了 the answer to it in two forums。我必须在我的 Select 值步骤中设置一些字段,这样它才能理解我的格式:
格式十进制分组 
#,###.##, 。
如果有人能想到更好的东西,请在这里分享:-)
根据@LeonardoSibela 的建议和自我回答,问题出在格式上。
理想情况下,两台机器之间除了某些特定于 JVM 的行为(例如 class 加载)外,不应有显着差异。
那到底有什么不同呢?系统的区域设置。
例如,如果您的 Linux 服务器设置为知道 #,###.##
的区域设置,但数据根于具有知道 #.###,##
的区域设置的系统,您有一个 (可解)问题。
正如您在自己的回答中提到的,您必须让流程知道提供数据的格式。
即:
- 格式:
#.###,##
- 十进制:
,
- 分组:
.