Mule splitter using regex returned no results

吃可爱长大的小学妹 提交于 2020-01-06 08:21:18

问题


I'm trying to split a csv file on lines. For this, I've tried alternatively with the following splitters on my flow:

<splitter expression="#[regex('^')]" doc:name="Splitter"/>

<splitter expression="#[regex('\n')]" doc:name="Splitter"/>

<splitter expression="#[regex('.*')]" doc:name="Splitter"/>

However, though the file has many lines, I'm getting the following message on the logs:

Splitter returned no results. If this is not expected, please check your split expression

回答1:


Finally, I found a tutorial here with the solution: http://www.dotnetfunda.com/articles/show/2070/using-mule-studio-to-read-csv-comma-seperated-value-data-from-fileinbo

The splitter has to be configured this way:

    <splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter" />

And that requires the following element to be included on the flow:

<configuration doc:name="Configuration">
    <expression-language autoResolveVariables="true">
        <import class="org.mule.util.StringUtils" />
    </expression-language>
</configuration>



回答2:


This expression works for splitting CSV file :-

<splitter expression="#[StringUtils.split(message.payload, '\n\r')]" doc:name="Splitter_For_MultipleRow"/>

And if your CSV files have a column headers like Name, Age etc .. you can use this :-

<splitter expression="#[rows=StringUtils.split(message.payload, '\n\r');ArrayUtils.subarray(rows,1,rows.size())]" doc:name="Splitter_For_MultipleRow"></splitter>


来源:https://stackoverflow.com/questions/25487736/mule-splitter-using-regex-returned-no-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!