KX Community

Find answers, ask questions, and connect with our KX Community around the world.

Home Forums kdb+ All that jazz: The librarians song

  • All that jazz: The librarians song

    Posted by sjt on May 2, 2022 at 12:00 am

    Because q is a proprietary language, most of us know it as a language we learned in order to query large datasets. But q is a general-purpose programming language. The 32-bit interpreter is free for non-commercial use. Its a great tool for general hacking. And lots of datasets need a little hacking.

    This is the story of how I used q to hack metadata from 700+ WAV file names for import into Apple Music.

     

    Cleaning up a dataset, finding and fixing problems, is always exploratory, and we get a taste of just how lively and responsive the q REPL is for this work. We use qSQL queries but the work also dips into their functional forms. (We also discover some ways to prevent Apple Music overriding our metadata.)

    The script is also an example of functional vector programming in practice.

    There is plenty of iteration in the computation but few signs of it in the code. Many of the q primitives, and all qSQL queries, iterate implicitly. Where iteration needs specifying , iteration operators are used, but even these are used sparsely. (It is a common qbie error to use iteration operators when iteration is already implicit.)

    There is no use of the do or while control words, and only a single if in the entire script.

    Only three functions require multiple lines to define them; the longest has six.

    There is also a preference for tacit forms rather than lambdas or setting variables that are read immediately and never used again.

    Find the full article and code on GitHub.

    sjt replied 1 month, 1 week ago 2 Members · 1 Reply
  • 1 Reply
  • davidcrossey

    Member
    March 5, 2022 at 12:00 am

    Jazz and vector programming are both difficult skills to grasp but very rewarding when one does become somewhat proficient.

    Fascinating application of q to clean up your music library, and a fantastic article & post demonstrating the strengths of the language – thanks for sharing with the community Stephen!

Log in to reply.