Skip to main content
Announcements
Marching toward a simplified navigation! READ ON
cancel
Showing results for 
Search instead for 
Did you mean: 
jono19872002
Contributor II
Contributor II

Store one table into multiple files

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 

Labels (1)
1 Solution

Accepted Solutions
lironbaram
Partner - Master III
Partner - Master III

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;

 

 

View solution in original post

1 Reply
lironbaram
Partner - Master III
Partner - Master III

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;