EasyETL.Net icon indicating copy to clipboard operation
EasyETL.Net copied to clipboard

Sum function in ETL

Open weedkiller opened this issue 6 years ago • 3 comments

Hello, I am parsing a CSV file, and creating an in mem table, I also want to perform a Sum on import, how can I set that up with your lib?

thanks

weedkiller avatar Apr 05 '19 19:04 weedkiller

Hi,

Sorry for the delayed response. You should be able to data a sum of all columns in the table by using the Compute method in the datatable. ie., if you declared a RegexDataSet as rds, you can call rds.Tables[0].Compute("Sum(Price)","ItemName='Popcorn'").

https://docs.microsoft.com/en-us/dotnet/api/system.data.datatable.compute?view=netframework-4.8

raelango avatar Aug 02 '19 19:08 raelango

Wow this is nice, never knew it was there.

One issue is that, I am performing a groupby or filtering down records select prior to this, so is this something I can perform and chain code... EasyETL.Table(Custoemr).groupBy(employee== @"john").Sum()...

weedkiller avatar Aug 28 '19 18:08 weedkiller

Hi,

Happy to see that you are attempting to use this.

Kindly make sure you are downloading the latest branch. The current latest branch is 1.3

https://github.com/raelango/EasyETL.Net/tree/1.3

Try running the EasyXMLSample project. This one has the usage of the EasyXMLDocument.Transform method. This method allows you to transform xml from one format to another in a chained manner.

You can set an array of string similar to below: (See the .transforms file in the bin\debug folder of EasyXmlSample project for more examples)

[row=>PatientVisit] Add SNo AutoNumber Add DispCode substring-before(Disposition,' ') filter starts-with(PatientName,'W') or Disposition='05 Eloped' filter starts-with(PrimaryNurse,'MURRAY') and starts-with(Disposition,'02') GO Add SNo1 SNo+1 Add Val 'Test Value' sort AgeGen

This would transform the source XML to destination XML and you can do a XML to DataSet to convert into a dataset that can be rendered in the UI or use one of the datasetWriters to Write in a specific format.

The Transform method supports the following commands:

  1. [OldTableName=>NewTableName] --- changes name of the table
  2. ADD ColumnName AUTONUMBER or formula or Constant -- add a column with or without a formula, constant or AUTONUMBER. Formula has to be in XSLT1.0 format.
  3. HIDE/REMOVE ColumnName -- removes the column
  4. RENAME OldColumnName NewColumnName -- changes the name of the column
  5. FILTER filtercommand --- filters to matching rows. filtercommand has to be in XSLT1.0 format
  6. SORT/SORTBY/ORDER/ORDERBY ColumnName -- order the recordset by columnname
  7. GO/EXECUTE -- Processes the input XML with all commands in the preceding lines to form an intermediary XML. This XML will be used as input XML for subsequent commands

Again, thanks for trying the EasyETL solution. I hope this is of value for you.

Thanks R. Arasu Elango


From: weedkiller [email protected] Sent: Wednesday, August 28, 2019 2:18 PM To: raelango/EasyETL.Net [email protected] Cc: Arasu Elango [email protected]; Comment [email protected] Subject: Re: [raelango/EasyETL.Net] Sum function in ETL (#3)

Wow this is nice, never knew it was there.

One issue is that, I am performing a groupby or filtering down records select prior to this, so is this something I can perform and chain code... EasyETL.Table(Custoemr).groupBy(employee== @"john").Sum()...

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/raelango/EasyETL.Net/issues/3?email_source=notifications&email_token=AH3655ZNKLCHH3HIM6476KLQG26QRA5CNFSM4HD6HQPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5MASTA#issuecomment-525863244, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH365556U7UZF56D3KIRXWDQG26QRANCNFSM4HD6HQPA.

raelango avatar Aug 28 '19 18:08 raelango