The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
How to flatten a collection of ducument into a data file
subhasisdasgupt
Member Posts: 15 Contributor II
I wanted to extract only a portion of documents using keep document part operator. Since this operator takes a single document at a time and then do the operation, I had to first filter the documents which contain the word "Battery" and then keep a portion of that document which is related mainly to battery inside the Loop Collection operator. I want the output to be a flat file (an excel or .csv) which contains only the output from Loop Collection operator and I am not in a position to do that. Document to data operator is also not solving the problem. I simply gives output in line with filter document operator. I am attaching the xml below. Any suggestion in solving this problem will be highly regarded.
Thanks in advance
Subhasis
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.015">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="text:create_document" compatibility="5.3.002" expanded="true" height="60" name="Create Document" width="90" x="45" y="30">
<parameter key="text" value="AFTER USING APPLE FOR MORE THAN 2 YEARS, I WAS HESISTANT TO SWITCH TO ANDROID, NO PHONE IN THE MARKET COULD TEMPT ME EXCEPT THIS ONE . "/>
</operator>
<operator activated="true" class="text:create_document" compatibility="5.3.002" expanded="true" height="60" name="Create Document (3)" width="90" x="45" y="120">
<parameter key="text" value="DISPLAY IS FANTASTIC, CAMERA PERFORMANCE IS CLASS APART, MOTION SENSORS ARE AMAZING AND SMART ENOUGH, BATTERY LIFE IS REALLY REALLY GOOD . "/>
</operator>
<operator activated="true" class="text:create_document" compatibility="5.3.002" expanded="true" height="60" name="Create Document (4)" width="90" x="45" y="210">
<parameter key="text" value="STYLISH.WITH FLIP COVER AND GOOD BATTERY BACKUP THEN THIS IS THE BEST PHONE . "/>
</operator>
<operator activated="true" class="collect" compatibility="5.3.015" expanded="true" height="112" name="Collect" width="90" x="313" y="30"/>
<operator activated="true" class="flatten_collection" compatibility="5.3.015" expanded="true" height="60" name="Flatten Collection" width="90" x="447" y="30"/>
<operator activated="true" class="text:filter_documents_by_content" compatibility="5.3.002" expanded="true" height="76" name="Filter Documents (by Content)" width="90" x="581" y="30">
<parameter key="string" value="battery"/>
</operator>
<operator activated="true" class="loop_collection" compatibility="5.3.015" expanded="true" height="76" name="Loop Collection" width="90" x="715" y="30">
<process expanded="true">
<operator activated="true" class="text:keep_document_parts" compatibility="5.3.002" expanded="true" height="60" name="Keep Document Parts (3)" width="90" x="112" y="30">
<parameter key="extraction_regex" value="[\sA-Z0-9]+(BATTERY)[\sA-Z0-9']+|[.,]?\s?(BATTERY)[,]?[\sA-Z0-9']+"/>
</operator>
<connect from_port="single" to_op="Keep Document Parts (3)" to_port="document"/>
<connect from_op="Keep Document Parts (3)" from_port="document" to_port="output 1"/>
<portSpacing port="source_single" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<connect from_op="Create Document" from_port="output" to_op="Collect" to_port="input 1"/>
<connect from_op="Create Document (3)" from_port="output" to_op="Collect" to_port="input 2"/>
<connect from_op="Create Document (4)" from_port="output" to_op="Collect" to_port="input 3"/>
<connect from_op="Collect" from_port="collection" to_op="Flatten Collection" to_port="collection"/>
<connect from_op="Flatten Collection" from_port="flat" to_op="Filter Documents (by Content)" to_port="documents 1"/>
<connect from_op="Filter Documents (by Content)" from_port="documents" to_op="Loop Collection" to_port="collection"/>
<connect from_op="Loop Collection" from_port="output 1" 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>
Thanks in advance
Subhasis
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.3.015">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="5.3.015" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="text:create_document" compatibility="5.3.002" expanded="true" height="60" name="Create Document" width="90" x="45" y="30">
<parameter key="text" value="AFTER USING APPLE FOR MORE THAN 2 YEARS, I WAS HESISTANT TO SWITCH TO ANDROID, NO PHONE IN THE MARKET COULD TEMPT ME EXCEPT THIS ONE . "/>
</operator>
<operator activated="true" class="text:create_document" compatibility="5.3.002" expanded="true" height="60" name="Create Document (3)" width="90" x="45" y="120">
<parameter key="text" value="DISPLAY IS FANTASTIC, CAMERA PERFORMANCE IS CLASS APART, MOTION SENSORS ARE AMAZING AND SMART ENOUGH, BATTERY LIFE IS REALLY REALLY GOOD . "/>
</operator>
<operator activated="true" class="text:create_document" compatibility="5.3.002" expanded="true" height="60" name="Create Document (4)" width="90" x="45" y="210">
<parameter key="text" value="STYLISH.WITH FLIP COVER AND GOOD BATTERY BACKUP THEN THIS IS THE BEST PHONE . "/>
</operator>
<operator activated="true" class="collect" compatibility="5.3.015" expanded="true" height="112" name="Collect" width="90" x="313" y="30"/>
<operator activated="true" class="flatten_collection" compatibility="5.3.015" expanded="true" height="60" name="Flatten Collection" width="90" x="447" y="30"/>
<operator activated="true" class="text:filter_documents_by_content" compatibility="5.3.002" expanded="true" height="76" name="Filter Documents (by Content)" width="90" x="581" y="30">
<parameter key="string" value="battery"/>
</operator>
<operator activated="true" class="loop_collection" compatibility="5.3.015" expanded="true" height="76" name="Loop Collection" width="90" x="715" y="30">
<process expanded="true">
<operator activated="true" class="text:keep_document_parts" compatibility="5.3.002" expanded="true" height="60" name="Keep Document Parts (3)" width="90" x="112" y="30">
<parameter key="extraction_regex" value="[\sA-Z0-9]+(BATTERY)[\sA-Z0-9']+|[.,]?\s?(BATTERY)[,]?[\sA-Z0-9']+"/>
</operator>
<connect from_port="single" to_op="Keep Document Parts (3)" to_port="document"/>
<connect from_op="Keep Document Parts (3)" from_port="document" to_port="output 1"/>
<portSpacing port="source_single" spacing="0"/>
<portSpacing port="sink_output 1" spacing="0"/>
<portSpacing port="sink_output 2" spacing="0"/>
</process>
</operator>
<connect from_op="Create Document" from_port="output" to_op="Collect" to_port="input 1"/>
<connect from_op="Create Document (3)" from_port="output" to_op="Collect" to_port="input 2"/>
<connect from_op="Create Document (4)" from_port="output" to_op="Collect" to_port="input 3"/>
<connect from_op="Collect" from_port="collection" to_op="Flatten Collection" to_port="collection"/>
<connect from_op="Flatten Collection" from_port="flat" to_op="Filter Documents (by Content)" to_port="documents 1"/>
<connect from_op="Filter Documents (by Content)" from_port="documents" to_op="Loop Collection" to_port="collection"/>
<connect from_op="Loop Collection" from_port="output 1" 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>
0
Answers
I introduced "appendData" together with "Documents to Data". Please take a look at the following process: