2010/12/20 uap12 <anders.u.pers...@gmail.com>

> Hi,
> I just started a hobby project, it download a webbpage, and extract number
> data witch exits between <br>Start rad:</SPAN>   --and --  </TD>
> Example
> <br>Start rad:</SPAN>01 20 20 52 32 85 89</TD>
>
> Everything works fine exept -main witch gives a error i don't understand.
> Becurse i try to learn Clojure, i like to now what's wrong a way :)
>
> Here is my code
> ============
> (ns com.persson.extract
>     ;(:import )
>     ;(:require )
> )
>
> (defn remove-endlines [file]
>   (filter #(not= % \newline)
>     (filter #(not= % \return) file)))
>
> (defn get-file-without-endlines[file]
>     (remove-endlines (slurp file) ))
>
> (defn -main[]
>     (re-find #"<br>Start rad:<\/SPAN>*.<\/TD>" (get-file-without-endlines
> "E:/testing/data/1999_1.txt" )))
>
> And here is the error
>
> ---------------------------------------------------------------------------------------------------------------------------------------
> com.persson.extract=> (-main)
> #<CompilerException java.lang.ClassCastException: clojure.lang.LazySeq
> cannot be cast to java.lang.CharSequence (NO_SOURCE_FILE:117)>
>
>
The return value of get-file-without-endlines will be a seq of Chars, while
re-find expects a CharSequence (generally a String).
So to follow in the spirit of your example, you'd have to first convert your
seq of Chars back into a string, e.g. via
(apply str (get-file-without-endlines ....))

HTH,

-- 
Laurent


> Best regards
> Anders
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to