# How to use KDB as a command line?

**URL:** <https://forum.kx.com/t/how-to-use-kdb-as-a-command-line/6745>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [October 17, 2010, 6:00pm UTC](https://forum.kx.com/t/how-to-use-kdb-as-a-command-line/6745 "2010-10-17T18:00:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LunaMoon](https://avatars.discourse-cdn.com/v4/letter/l/9d8465/32.png) [@LunaMoon](https://forum.kx.com/u/LunaMoon)\
**Post date:** [October 17, 2010, 6:00pm UTC](https://forum.kx.com/t/how-to-use-kdb-as-a-command-line/6745/1 "2010-10-17T18:00:00Z")

</div>

Hi all,Sorry I am really a newbie. I spent a lot time on the followingproblem and couldn’t find a solution. Could you please help me?I have a csv file, which contains the tick data with the followingformat:timestamps, bp, bs, ap, as, tp, ts-----------------------------------------------------20101014 09:00:0020101014 09:05:00Of course these are event data but I would like to convert them intosnapshot data. That’s to say, I would like to find the "outstanding"bp, ap, and tp at certain time as a snapshot. For example, if there isno activity between 09:00:00 and 09:05:00, then if I query the statusat 09:05:00 as a snapshot, I should get the ap, bp and tp at09:00:00.I would like to create such a function with the date/time as input andthe “outstanding” quotes/prices as outputs..How to do that?And is there a way to use KDB as a command line: i.e. by executing:q MyFunc.q MyFile.csv 20101014 09:05:00 \> MyOutputs.csv------------------------------------How to do the above in q/KDB?Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Attila](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@Attila](https://forum.kx.com/u/Attila)\
**Post date:** [October 18, 2010, 9:42am UTC](https://forum.kx.com/t/how-to-use-kdb-as-a-command-line/6745/2 "2010-10-18T09:42:00Z")

</div>

aj  
? Attila
