2016-10-19 11 views
0

Я хочу создать файл csv как вывод, но в потоке есть NULL. Я установить выходной конфигурации Текстовый файл, как это:Как я могу заключить значения с двойными кавычками в PDI?

Вкладка Содержание:

separator --> , 

    enclosure: --> " 

    force the enclosure around fields? --> yes 

поля вкладки:

Null --> "" 

Я использую версию чайник 6.0, используя выше конфигурации, то нулевые значения заменяясь строкой "" "" "", если я не устанавливаю значение по умолчанию для элемента Null на вкладке полей, значения Null не будут заключены в двойные кавычки в выходном файле csv. Как я могу сгенерировать CSV-файл с правильным выходом?

Заранее спасибо.

+0

Что вы ожидаете в выходной файл? Ожидаете ли вы «Null»? – Nikhil

+0

Я бы хотел ожидать «», но значение по умолчанию «», установленное вручную, не влияет, выходной файл теряет двойные кавычки. –

ответ

0

Вот ваше решение:

  1. Не заставляйте корпус в выходной текстовый файл
  2. Remove "" из полей -> Null
  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

спасибо, я уже нашел способ сделать это. –

 Смежные вопросы

  • Нет связанных вопросов^_^