# Iterate saving down a table

**URL:** <https://forum.kx.com/t/iterate-saving-down-a-table/9808>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [May 11, 2015, 3:37pm UTC](https://forum.kx.com/t/iterate-saving-down-a-table/9808 "2015-05-11T15:37:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![js610308](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@js610308](https://forum.kx.com/u/js610308)\
**Post date:** [May 11, 2015, 3:37pm UTC](https://forum.kx.com/t/iterate-saving-down-a-table/9808/1 "2015-05-11T15:37:00Z")

</div>

Hi, I’m trying to save down a date partitioned table to disk. Using the .Q.dpft[':/path/to/location;.z.d;'sym;‘tablename]. This woks fine. I want to do this multiple times at end of day to the various tables that exist., and so I’d like to enclose this in a function, and pass the table name(s)in iteratively, saving down each one, one at a time. But how do I do this given I won’t be writing the explicit name of the table for the last parameter, rather the local parameters name, so I think this doesn’t work. Eg savedata:{[tab;dt] .Q.dpft[’/home/dir/hdb;dt;'sym;'tab];} savedata[t;.z.d-1]. //t is table saved in memory. Regard, John

---

<div class="post-metadata">

**Author:** ![sohagan](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@sohagan](https://forum.kx.com/u/sohagan)\
**Post date:** [May 11, 2015, 3:56pm UTC](https://forum.kx.com/t/iterate-saving-down-a-table/9808/2 "2015-05-11T15:56:00Z")

</div>

Hi John,

dpft expects 4 params, so pass 3 variables and then run on each the 4th param(tnames).

Furthermore, the 4th param is table name, not table data,ie. `tab not tab, and I guess this is where you are seeing errors.&nbsp;

[http://code.kx.com/wiki/DotQ/DotQDotdpft](http://code.kx.com/wiki/DotQ/DotQDotdpft)

q)t2:t:(a:10?10;b:10?`2)

q).Q.dpft[`:./;.z.d;`b]each `t`t2

or

q).Q.dpft[`:./;.z.d;`b]each tables&nbsp;&nbsp;&nbsp; // if you want to save down all tables that are in memory at that time.&nbsp;

HTH,

Sean
