2016-10-19 1 views
0

出力としてCSVファイルを作成したいが、ストリームにいくつかのNULLがある。 二重引用符で値を囲むにはどうしたらいいですか?

コンテンツ]タブ

separator --> , 

    enclosure: --> " 

    force the enclosure around fields? --> yes 

フィールドタブ:私は上記の設定を使用して、ケトル6.0バージョンを使用

Null --> "" 

、NULL値である私は、このようなテキストファイルの出力設定を設定します"" ""文字列に置き換えられている場合、フィールドタブでNullのデフォルト値を設定しないと、ヌル値は出力csvファイルの二重引用符で囲まれません。正しい出力を持つCSVファイルを生成するにはどうすればよいですか?

ありがとうございます。ここで

+0

出力ファイルに期待していますか?あなたは "Null"を期待していますか? – Nikhil

+0

私は ""期待していますが、マニュアルで設定したデフォルト値は無効です。出力ファイルは二重引用符を失います。 –

答えて

0

はあなたのソリューションです:フィールドから

  1. テキストファイル出力のエンクロージャを強制しないでください
  2. 削除「」 - >ヌル
  3. 私の例を使用してください。それはあなたがやりたいだろう:

<?xml version="1.0" encoding="UTF-8"?> 
 
<transformation-steps> 
 
<steps> 
 
    <step> 
 
    <name>Data Grid</name> 
 
    <type>DataGrid</type> 
 
    <description/> 
 
    <distribute>Y</distribute> 
 
    <custom_distribution/> 
 
    <copies>1</copies> 
 
     <partitioning> 
 
      <method>none</method> 
 
      <schema_name/> 
 
      </partitioning> 
 
    <fields> 
 
     <field> 
 
     <name>Something</name> 
 
     <type>String</type> 
 
     <format/> 
 
     <currency/> 
 
     <decimal/> 
 
     <group/> 
 
     <length>-1</length> 
 
     <precision>-1</precision> 
 
     <set_empty_string>N</set_empty_string> 
 
     </field> 
 
    </fields> 
 
    <data> 
 
     <line> <item>asda</item> </line> 
 
     <line> <item/> </line> 
 
     <line> <item>sadasd</item> </line> 
 
     <line> <item/> </line> 
 
     <line> <item>asdads</item> </line> 
 
    </data> 
 
    <cluster_schema/> 
 
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI> 
 
     <xloc>159</xloc> 
 
     <yloc>125</yloc> 
 
     <draw>Y</draw> 
 
     </GUI> 
 
    </step> 
 

 
    <step> 
 
    <name>Text file output</name> 
 
    <type>TextFileOutput</type> 
 
    <description/> 
 
    <distribute>Y</distribute> 
 
    <custom_distribution/> 
 
    <copies>1</copies> 
 
     <partitioning> 
 
      <method>none</method> 
 
      <schema_name/> 
 
      </partitioning> 
 
    <separator>&#x3b;</separator> 
 
    <enclosure/> 
 
    <enclosure_forced>N</enclosure_forced> 
 
    <enclosure_fix_disabled>N</enclosure_fix_disabled> 
 
    <header>Y</header> 
 
    <footer>N</footer> 
 
    <format>DOS</format> 
 
    <compression>None</compression> 
 
    <encoding/> 
 
    <endedLine/> 
 
    <fileNameInField>N</fileNameInField> 
 
    <fileNameField/> 
 
    <create_parent_folder>Y</create_parent_folder> 
 
    <file> 
 
     <name>&#x24;&#x7b;Internal.Transformation.Filename.Directory&#x7d;&#x5c;file.txt</name> 
 
     <is_command>N</is_command> 
 
     <servlet_output>N</servlet_output> 
 
     <do_not_open_new_file_init>N</do_not_open_new_file_init> 
 
     <extention>csv</extention> 
 
     <append>N</append> 
 
     <split>N</split> 
 
     <haspartno>N</haspartno> 
 
     <add_date>N</add_date> 
 
     <add_time>N</add_time> 
 
     <SpecifyFormat>N</SpecifyFormat> 
 
     <date_time_format/> 
 
     <add_to_result_filenames>Y</add_to_result_filenames> 
 
     <pad>N</pad> 
 
     <fast_dump>N</fast_dump> 
 
     <splitevery>0</splitevery> 
 
    </file> 
 
    <fields> 
 
     <field> 
 
     <name>quotes_bounded_something</name> 
 
     <type>String</type> 
 
     <format/> 
 
     <currency/> 
 
     <decimal/> 
 
     <group/> 
 
     <nullif/> 
 
     <trim_type>none</trim_type> 
 
     <length>-1</length> 
 
     <precision>-1</precision> 
 
     </field> 
 
    </fields> 
 
    <cluster_schema/> 
 
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI> 
 
     <xloc>547</xloc> 
 
     <yloc>126</yloc> 
 
     <draw>Y</draw> 
 
     </GUI> 
 
    </step> 
 

 
    <step> 
 
    <name>Calculator</name> 
 
    <type>Calculator</type> 
 
    <description/> 
 
    <distribute>Y</distribute> 
 
    <custom_distribution/> 
 
    <copies>1</copies> 
 
     <partitioning> 
 
      <method>none</method> 
 
      <schema_name/> 
 
      </partitioning> 
 
     <calculation><field_name>quotes</field_name> 
 
<calc_type>CONSTANT</calc_type> 
 
<field_a>&#x22;</field_a> 
 
<field_b/> 
 
<field_c/> 
 
<value_type>String</value_type> 
 
<value_length>-1</value_length> 
 
<value_precision>-1</value_precision> 
 
<remove>N</remove> 
 
<conversion_mask/> 
 
<decimal_symbol/> 
 
<grouping_symbol/> 
 
<currency_symbol/> 
 
</calculation> 
 
     <calculation><field_name>prefixed_field</field_name> 
 
<calc_type>ADD</calc_type> 
 
<field_a>quotes</field_a> 
 
<field_b>Something</field_b> 
 
<field_c/> 
 
<value_type>String</value_type> 
 
<value_length>-1</value_length> 
 
<value_precision>-1</value_precision> 
 
<remove>N</remove> 
 
<conversion_mask/> 
 
<decimal_symbol/> 
 
<grouping_symbol/> 
 
<currency_symbol/> 
 
</calculation> 
 
     <calculation><field_name>quotes_bounded_something</field_name> 
 
<calc_type>ADD</calc_type> 
 
<field_a>prefixed_field</field_a> 
 
<field_b>quotes</field_b> 
 
<field_c/> 
 
<value_type>String</value_type> 
 
<value_length>-1</value_length> 
 
<value_precision>-1</value_precision> 
 
<remove>N</remove> 
 
<conversion_mask/> 
 
<decimal_symbol/> 
 
<grouping_symbol/> 
 
<currency_symbol/> 
 
</calculation> 
 
    <cluster_schema/> 
 
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI> 
 
     <xloc>279</xloc> 
 
     <yloc>125</yloc> 
 
     <draw>Y</draw> 
 
     </GUI> 
 
    </step> 
 

 
    <step> 
 
    <name>If field value is null</name> 
 
    <type>IfNull</type> 
 
    <description/> 
 
    <distribute>Y</distribute> 
 
    <custom_distribution/> 
 
    <copies>1</copies> 
 
     <partitioning> 
 
      <method>none</method> 
 
      <schema_name/> 
 
      </partitioning> 
 
     <replaceAllByValue/> 
 
     <replaceAllMask/> 
 
     <selectFields>Y</selectFields> 
 
     <selectValuesType>N</selectValuesType> 
 
     <setEmptyStringAll>N</setEmptyStringAll> 
 
    <valuetypes> 
 
     </valuetypes> 
 
    <fields> 
 
     <field> 
 
     <name>quotes_bounded_something</name> 
 
     <value>&#x22;&#x22;</value> 
 
     <mask/> 
 
     <set_empty_string>N</set_empty_string> 
 
     </field> 
 
     </fields> 
 
    <cluster_schema/> 
 
<remotesteps> <input> </input> <output> </output> </remotesteps> <GUI> 
 
     <xloc>399</xloc> 
 
     <yloc>125</yloc> 
 
     <draw>Y</draw> 
 
     </GUI> 
 
    </step> 
 

 
</steps> 
 
<order> 
 
    <hop> <from>Data Grid</from><to>Calculator</to><enabled>Y</enabled> </hop> 
 
    <hop> <from>Calculator</from><to>If field value is null</to><enabled>Y</enabled> </hop> 
 
    <hop> <from>If field value is null</from><to>Text file output</to><enabled>Y</enabled> </hop> 
 
</order> 
 
<notepads> 
 
</notepads> 
 
<step_error_handling> 
 
</step_error_handling> 
 
</transformation-steps>

+0

ありがとう、私はすでにそれを行う方法を見つける。 –

関連する問題