Pages: [1]
  Print  
Author Topic: [SOLVED] Write TSV  (Read 1339 times)
4of4
Newbie
*
Posts: 7


« on: June 18, 2013, 01:30:49 AM »

Hi,
I need to write an "Example set" as a tsv file.
I'm trying to use the "Write CSV" operator.
What kind of value can I insert in "column separator" field?
The value "\t" seems to work only in "Read CSV" .....
Thanks in advance for support
« Last Edit: June 20, 2013, 02:16:48 PM by 4of4 » Logged
MacPhotoBiker
Jr. Member
**
Posts: 56


WWW
« Reply #1 on: June 18, 2013, 05:56:21 AM »

Are you looking to insert a tab separator? I'm not sure about that, but if you don't want to use any standard like comma or semi-colon, usually the pipe (|) is a commonly used option.
Logged

MacPhotoBiker
Just do your Core Business. We do the rest.
4of4
Newbie
*
Posts: 7


« Reply #2 on: June 18, 2013, 11:23:43 AM »

Thanks for suggestion, but unfortunately it doesn't work.
Here's the case
Bye

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.005">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.3.005" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="retrieve" compatibility="5.3.005" expanded="true" height="60" name="Retrieve Iris" width="90" x="112" y="120">
        <parameter key="repository_entry" value="//Samples/data/Iris"/>
      </operator>
      <operator activated="true" class="write_csv" compatibility="5.3.005" expanded="true" height="76" name="Write CSV" width="90" x="514" y="120">
        <parameter key="csv_file" value="C:\a.txt"/>
        <parameter key="column_separator" value="|"/>
        <parameter key="quote_nominal_values" value="false"/>
      </operator>
      <connect from_op="Retrieve Iris" from_port="output" to_op="Write CSV" to_port="input"/>
      <connect from_op="Write CSV" from_port="through" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>

Logged
MacPhotoBiker
Jr. Member
**
Posts: 56


WWW
« Reply #3 on: June 18, 2013, 03:56:43 PM »

Well, for me it works, below are the first four lines that your process generates:

a1|a2|a3|a4|id|label
5.1|3.5|1.4|0.2|id_1|Iris-setosa
4.9|3.0|1.4|0.2|id_2|Iris-setosa
4.7|3.2|1.3|0.2|id_3|Iris-setosa

Which error message are you getting?
Logged

MacPhotoBiker
Just do your Core Business. We do the rest.
4of4
Newbie
*
Posts: 7


« Reply #4 on: June 18, 2013, 04:39:28 PM »

No, msg error
The point is that I need that the columns are separated by Tab character to complete my data process .... This is a first part of an ETL process and the output file will be processed by another program .... that needs tab separators
Bye
Logged
MacPhotoBiker
Jr. Member
**
Posts: 56


WWW
« Reply #5 on: June 18, 2013, 05:00:52 PM »

I see, you definitely need the tab as a separator. I found the following to work for me, but I'm not sure if this is really a solution, or just a work around. Yet, it works for me.

I manually created a tab separated file, then I read it with the "read CSV" operator, and chose "tab" as separator (again, while READING). Then, I went to the settings of this operator, and just copied whatever was in the field "column separator). It looked empty, but I just double clicked in it, then copied. You may also just double click between the two brackets below, and copy (without the brackets)

(   )

Then, paste this as column separator into your "write CSV operator".

I hope that works, it did the job for me. I opened the generated file in LibreOffice and indicated "tab" as delimiter, and it opened as expected.
« Last Edit: June 18, 2013, 05:03:42 PM by MacPhotoBiker » Logged

MacPhotoBiker
Just do your Core Business. We do the rest.
MacPhotoBiker
Jr. Member
**
Posts: 56


WWW
« Reply #6 on: June 18, 2013, 05:06:04 PM »

I just realized that whatever I pasted between the brackets got lost when posting the message, sorry about that.

But just follow the procedure as I described, and copy the field separator value from the "read CSV" to the "write CSV operator", this should do the job.

I know it doesn't look very smooth, but I hope it gets you a step forward...

Or, here's the code for the operator:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.008">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.3.008" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="write_csv" compatibility="5.3.008" expanded="true" height="76" name="Write CSV" width="90" x="380" y="75">
        <parameter key="csv_file" value="/home/macphotobiker/Desktop/tsv.tsv"/>
        <parameter key="column_separator" value="&#9;"/>
      </operator>
      <connect from_op="Write CSV" from_port="through" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>
« Last Edit: June 18, 2013, 05:10:23 PM by MacPhotoBiker » Logged

MacPhotoBiker
Just do your Core Business. We do the rest.
Marius
Administrator
Hero Member
*****
Posts: 1794



WWW
« Reply #7 on: June 20, 2013, 01:30:45 PM »

The problem is that the Java framework does not allow to enter a tab character into the input field, because when pressing the tab key the cursor moves to the next field.

To get a tab character into the parameter, you have to copy it from somewhere. You can e.g. press tab in a normal text editor and copy the resulting (seemingly empty) character into RapidMiner.

Best regards,
Marius
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
4of4
Newbie
*
Posts: 7


« Reply #8 on: June 20, 2013, 02:15:52 PM »

Thank you very much, MacPhotoBiker!!!
Your solution works perfectly for my purpose !!!!!
Thanks also to Marius
Bye
Logged
MacPhotoBiker
Jr. Member
**
Posts: 56


WWW
« Reply #9 on: June 20, 2013, 02:23:10 PM »

Perfect 4of4, glad I could help.

Good luck with your project.
Logged

MacPhotoBiker
Just do your Core Business. We do the rest.
Pages: [1]
  Print  
 
Jump to: