Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
I have a table split by Customers which store into a CSV format ready to send out.
Is there a way that i dynamically can split this table into multiple CSVs based on the customer column.
For example i could manually Load into individual tables with a where clause, store then drop etc, but I want this to be a dynamic process if possible
hi
assuming your table is called Data
you could write a script like this :
///loading the data
Data:
Load *
From source ;
//////loading distinct values of customers
customers:
load distinct Customer
resident Data;
///looping through customers and saving a csv for each customer
for i = 0 to noofrows('customers')-1
let vCustomer = peek('Customer',$(i),'customers');
customerTable:
noconcatenate Load
*
Resident Data
where Customer = '$(vCustomer)';
store customerTable into [lib://customerFiles(admin)/customerTable_$(vCustomer).csv](txt);
drop table customerTable;
next
drop table customers;
hi
assuming your table is called Data
you could write a script like this :
///loading the data
Data:
Load *
From source ;
//////loading distinct values of customers
customers:
load distinct Customer
resident Data;
///looping through customers and saving a csv for each customer
for i = 0 to noofrows('customers')-1
let vCustomer = peek('Customer',$(i),'customers');
customerTable:
noconcatenate Load
*
Resident Data
where Customer = '$(vCustomer)';
store customerTable into [lib://customerFiles(admin)/customerTable_$(vCustomer).csv](txt);
drop table customerTable;
next
drop table customers;