Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all.
I have file that should be loaded by parts based on dates in it.
Lets say I have file with some dates data in it like below.
And I need to load this file by parts for each 4 days starting from the oldest date. Like first iteration should be 20/07/2023 - 23/07/2023, second - 24/07/2023 - 27/07/2023, third - 28/07/2023 - 30/07/2023.
How to make such split correctly? Or is it possible to do at all?
You may take a similar approach as starting point to create the needed loop-information, for example by:
DateList:
load date(startdate + recno() - 1) as Date, ceil(recno() / 4) as DateGroup
autogenerate enddate - startdate;
DateGroup:
load DateGroup, concat(Date, ',') as DateString
resident DateList group by DateGroup;
and then using fieldvaluelist() and/or fieldvalue() or peek() to loop through these tables and picking the needed Date or DateString or similar created information into a variable to prepare an appropriate where-clause or adjusting the file-name with it.
It's not quite clear what do you mean with split the files but the following would provide a key-value with an appropriate grouping:
load *, ceil(rowno() / 4) as DateGroup
resident Source order by date_time desc;
Thank you for you reply @marcus_sommer . Unfortunately this idea does not works for me. I have large xml file in some web site. And once I need to load it. I can't do this because time of connection with this source is limited and I just can't load it all at once .
So I decided try to create some loop where I may set date period and load part of xml data during connection is open. Than reconnect , take another part and concatenate it with previous loaded data. And repeat this loop until I will get all xml file.
You may take a similar approach as starting point to create the needed loop-information, for example by:
DateList:
load date(startdate + recno() - 1) as Date, ceil(recno() / 4) as DateGroup
autogenerate enddate - startdate;
DateGroup:
load DateGroup, concat(Date, ',') as DateString
resident DateList group by DateGroup;
and then using fieldvaluelist() and/or fieldvalue() or peek() to loop through these tables and picking the needed Date or DateString or similar created information into a variable to prepare an appropriate where-clause or adjusting the file-name with it.
Thanks @marcus_sommer ! Will try to implement this example into my solution.