FAQ
I need to retrieve data between a range of timestamps .
my code looks like :
In the query below i am passing two timestamps and i need to pull ?value
  field between these two dates .

(def info

       (hfs-delimited "/file"

                        :delimiter ";"

                        :outfields ["?timestamp" "?category" "?name" "?value"
]

                        :classes[String String String Float]

                        :skip-header? false))

(def info-tap

   (<- [?timestamp ?value]

       ((select-fields info ["?timestamp" "?value"]) ?timestamp ?value)))


(def dateto "12.05.2010 00:15:00")

(def datefrom "12.05.2010 00:10:00")


(?<- (stdout) [?timestamp ?value]

   (info-tap ?timestamp ?value)

   (> ?timestamp datefrom)

   (< ?timestamp dateto)

)


Here applying > or < on String "?timestamp" field does not make sense . i
cannot even cast it to Float . So How do i deal with it ?

or should i try using cli-time of clojure somehow ? I guess there is no
internal class for timestamp in cascalog -

--
You received this message because you are subscribed to the Google Groups "cascalog-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascalog-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • David Kincaid at Apr 20, 2014 at 9:50 pm
    Yes, you'll need to use clj-time or something similar to convert all your
    date strings into something you can compare. clj-time.format namespace has
    the functions that you'll need.
    On Sunday, April 20, 2014 3:59:40 PM UTC-5, sindhu hosamane wrote:

    I need to retrieve data between a range of timestamps .
    my code looks like :
    In the query below i am passing two timestamps and i need to pull ?value
    field between these two dates .

    (def info

    (hfs-delimited "/file"

    :delimiter ";"

    :outfields ["?timestamp" "?category" "?name"
    "?value"]

    :classes[String String String Float]

    :skip-header? false))

    (def info-tap

    (<- [?timestamp ?value]

    ((select-fields info ["?timestamp" "?value"]) ?timestamp ?value)))


    (def dateto "12.05.2010 00:15:00")

    (def datefrom "12.05.2010 00:10:00")


    (?<- (stdout) [?timestamp ?value]

    (info-tap ?timestamp ?value)

    (> ?timestamp datefrom)

    (< ?timestamp dateto)

    )


    Here applying > or < on String "?timestamp" field does not make sense . i
    cannot even cast it to Float . So How do i deal with it ?

    or should i try using cli-time of clojure somehow ? I guess there is no
    internal class for timestamp in cascalog -
    --
    You received this message because you are subscribed to the Google Groups "cascalog-user" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to cascalog-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sindhu hosamane at Apr 23, 2014 at 12:05 pm
    I have been using clj-time of clojure to deal with timestamp now . But i
    have problems in a loop
    to get results using cascalog query . Can anyone tell me how do i update my
    timestamp to the incremented value of timestamp .
    I want my query to print timestamp and values between datefrom and dateto . Any
    help would be appreciated.
    Below is my code snippet :


    (def datefrom "12:05:2010 00:00:00")

      (def dateto "12:05:2010 01:01:00")


    (def custom-formatter (f/formatter "dd:MM:yyyy HH:mm:ss"))

    (def hour-part (t/hour (f/parse custom-formatter datefrom)))

    (def minute-part(t/minute (f/parse custom-formatter datefrom)))


    (loop [hour-part 01]

       (when (>= minute-part 00)

         (?<- (stdout) [?timestamp-out ?value-out]

       (info-tap ?timestamp ?value) (c/limit [1] ?timestamp ?value :>?timestamp-out ?value-out
    )

        )

      (recur (+ minute-part 01))))


    my data looks like :

    12:05:2010 00:00:00;GasTurbine2103/01;TC255;78.99

    12:05:2010 00:01:00;GasTurbine2103/01;TC255;77.599

    12:05:2010 00:02:00;GasTurbine2103/01;TC255;77.199

    12:05:2010 00:03:00;GasTurbine2103/01;TC255;77.

    12:05:2010 00:04:00;GasTurbine2103/01;TC255;76.699

    12:05:2010 00:05:00;GasTurbine2103/01;TC255;76.5

                      ..

                      ..

    12:05:2010 01:00:00;GasTurbine2103/01;TC255;60.299

                      ..

                      ..


    The result prints only first entry 12:05:2010 00:00:00 78.99 each time loop
    is executed.

    --
    You received this message because you are subscribed to the Google Groups "cascalog-user" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to cascalog-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcascalog-user @
categoriesclojure, hadoop
postedApr 20, '14 at 8:59p
activeApr 23, '14 at 12:05p
posts3
users2
websiteclojure.org
irc#clojure

2 users in discussion

Sindhu hosamane: 2 posts David Kincaid: 1 post

People

Translate

site design / logo © 2021 Grokbase