Using arithmetic ( addition) in a graph

Discussion on developing CloverETL engine, transformation components etc.

leftee96
Posts: 1
Joined: Tue Mar 22, 2016 7:58 pm

Using arithmetic ( addition) in a graph

Postby leftee96 » Tue Mar 22, 2016 8:57 pm

Hello - I am a beginner here and I have a question. I am building a graph for a flat file. In this file I have eight columns that I need to add together if the 'source code' match. For example - I have the following

Src1 = A SrcAmount1 = 1000.00, Src2 = P SrcAmount2 = 100.00, Src3 = A SrcAmount3 = 100.00

I would need to add Src A together for a total of 1,100.00. I have eight Src codes and eight corresponding SrcAmounts in one row. I have several rows but only need to look across one row at a time.

I am not sure how to code this in the graph

Thank You

cholastal
Posts: 102
Joined: Tue Sep 01, 2015 1:22 pm

Re: Using arithmetic ( addition) in a graph

Postby cholastal » Wed Mar 30, 2016 2:40 pm

Hi,

The structure of the file prevents direct addition of the SrcAmount values. Each column contains too much information. You need to separate the Src from the SrcAmount. This can be done in a Reformat component using string functions like replace() and split(). I attached an example graph, where you can find the Reformat component (renamed to Parse & Count in this example) which contains commented code (in the Transform property). Output of this component is the result of the addition.

using_arithmetic.grf
(3.21 KiB) Downloaded 36 times

ua_test.csv
input file
(91 Bytes) Downloaded 32 times

Hope this helps,
---
Lukas Cholasta
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com
How to speed up communication with CloverCARE support


cron