Input collection: myOrders37
OrderID | Item | UnitsOrdered | CostPerUnit |
1001 | Notebook | 25 | 2.5 |
1002 | Crayons | 15 | 8.62 |
1003 | Binders | 10 | 13.34 |
1004 | Pencils | 21 | 1.5 |
1005 | Erasers | 30 | 0.89 |
Output to datasource: mySolution37
OrderID,Item,UnitsOrdered,CostPerUnit 1001,Notebook,25,2.5 1002,Crayons,15,8.62 1003,Binders,10,13.34 1004,Pencils,21,1.5 1005,Erasers,30,0.89 |
Solution code:
//Create a collection
ClearCollect(myOrders37,
{OrderID: 1001, Item: "Notebook", UnitsOrdered: 25, CostPerUnit: 2.5},
{OrderID: 1002, Item: "Crayons", UnitsOrdered: 15, CostPerUnit: 8.62},
{OrderID: 1003, Item: "Binders", UnitsOrdered: 10, CostPerUnit: 13.34},
{OrderID: 1004, Item: "Pencils", UnitsOrdered: 21, CostPerUnit: 1.5},
{OrderID: 1005, Item: "Erasers", UnitsOrdered: 30, CostPerUnit: 0.89}
);
//Collection to CSV code
ClearCollect(myCSV,{csvString:"OrderID,Item,UnitsOrdered,CostPerUnit"&Char(10)});
ForAll(
myOrders37,
Patch(
myCSV,
First(myCSV),
{csvString: First(myCSV).csvString&OrderID&","&Item&","&UnitsOrdered&","&CostPerUnit&Char(10)})
);
Set(mySolution37,First(myCSV).csvString)