Java数据转换引擎 - Data Pipeline
fmms
13年前
<p>Data Pipeline 是一个Java的数据转换工具包,主要的功能包括:</p> <p>* 读: CSV, fixed-width, Excel, database, weblogs, custom<br /> * 写: CSV, fixed-width, Excel, database, PDF, Word, XML, custom<br /> * 操作: validate, filter, sort, lookup, 去除重复数据, convert, throttle, calculate, custom, and more<br /> * 运行时表达式过滤器、数据验证以及公式计算</p> <p><img alt="Java数据转换引擎 - Data Pipeline" src="https://simg.open-open.com/show/1f0920ea9878bc939ff6b43c38f50aaf.jpg" width="328" height="660" /><br /> <br /> 典型的应用场景包括:<br /> 1. 读取 CSV 文件<br /> 2. 删除重复的记录<br /> 3. 添加计算列<br /> 4. 删除无用的列<br /> 5. 数据保存到数据库</p> <p>代码示例:</p> <pre class="brush:java; toolbar: true; auto-links: false;">DataReader reader = new CSVReader(new File("credit-balance.csv")) .setFieldNamesInFirstRow(true); // Use only the "Rating" and "CreditLimit" fields in duplicate test reader = new RemoveDuplicatesReader(reader, new FieldList("Rating", "CreditLimit")); // Add AvailableCredit field, remove "CreditLimit", "Balance" fields reader = new TransformingReader(reader) .add(new SetCalculatedField("AvailableCredit", "parseDouble(CreditLimit) - parseDouble(Balance)")) .add(new ExcludeFields("CreditLimit", "Balance")); DataWriter writer = new JdbcWriter(getJdbcConnection(), "dp_credit_balance") .setAutoCloseConnection(true); JobTemplate.DEFAULT.transfer(reader, writer);</pre> <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326935502655" target="_blank">http://www.open-open.com/lib/view/home/1326935502655</a></p> <p></p>