Re: Property file IO failing Incorrect data type conversion

2017-04-15 Thread manas . marthi
Hi Sean, Thank you very much. I changed read-string to str. And it worked fine now. So is ".toString" working fine. for [[k v] props] [(keyword k) (.toString v)] regards Manas On Saturday, April 15, 2017 at 2:28:16 AM UTC+1, Sean Corfield wrote: > > Trying to convert arbitrary strings to Cl

Re: Property file IO failing Incorrect data type conversion

2017-04-14 Thread Sean Corfield
Trying to convert arbitrary strings to Clojure objects via read-string is rather dangerous – read-string can execute arbitrary code (if the string happens to look like a tagged literal). Aside from that, read-string is only going to read the first expression from the string:

Property file IO failing Incorrect data type conversion

2017-04-14 Thread manas . marthi
Hi I am trying to compare two eclipse preferences files with a piece of code I picked from internet Some of the values in the file are version numbers and clojure is throwing number format error. How to force clojure read the properties as strings. CompilerException java.lang.NumberForm

Re: file io

2009-03-30 Thread Stuart Sierra
On Mar 26, 1:34 pm, Victor Rodriguez wrote: > (defmacro with-out-as >   [f & body] >   `(with-open [w# (writer ~f)] >      (binding [*out* w#] >       �...@body))) I've added something very similar to this to clojure.contrib.duck- streams. -Stuart Sierra --~--~-~--~~~---

Re: file io

2009-03-29 Thread Korny Sietsma
sweet :) - Korny On Fri, Mar 27, 2009 at 4:34 AM, Victor Rodriguez wrote: > > On Tue, Mar 24, 2009 at 11:05 PM, Korny Sietsma wrote: > > It'd be nice to have a macro that worked more like the first example - > > "spit" is great for one-liners, but the fact that it opens and closes the > > file

Re: file io

2009-03-26 Thread Victor Rodriguez
On Tue, Mar 24, 2009 at 11:05 PM, Korny Sietsma wrote: > It'd be nice to have a macro that worked more like the first example - > "spit" is great for one-liners, but the fact that it opens and closes the > file each time you call it seems a bit painful for anything more complex. > Something that

Re: file io

2009-03-25 Thread Korny Sietsma
ome of the examples >> >>> interesting. >> >>> >> >>> http://paste.pocoo.org/show/109498/ >> >>> >> >>> On Mar 24, 11:20 am, e wrote: >> >>> > is there something as simple as this in clojure? >>

Re: file io

2009-03-25 Thread e
>>> On Mar 24, 11:20 am, e wrote: > >>> > is there something as simple as this in clojure? > >>> > > >>> > whole python program: > >>> > > >>> > of = open(filename,"w") > >>> >

Re: file io

2009-03-25 Thread Mark McGranaghan
gt;> >     of.write("hello") >>> >     of.close() >>> > >>> > I checked the api and looked around the wiki and google quickly and saw >>> > how >>> > to use java's stuff to do it ... but, welll... >>> >

Re: file io

2009-03-25 Thread Laurent PETIT
) >> > of.write("hello") >> > of.close() >> > >> > I checked the api and looked around the wiki and google quickly and saw >> how >> > to use java's stuff to do it ... but, welll... >> > >> > I noticed "

Re: file io

2009-03-25 Thread Korny Sietsma
gt; to use java's stuff to do it ... but, welll... > > > > I noticed "slurp" in the api for reading ... but only the whole file at > once > > (read() but no readline()). Is there something symmetrical for writing > > (outputting)? Is there a web page calle

Re: file io

2009-03-25 Thread Rayne
he api for reading ... but only the whole file at once > (read() but no readline()).  Is there something symmetrical for writing > (outputting)?  Is there a web page called "File IO" somewhere? > > Thanks. --~--~-~--~~~---~--~~ You received this me

Re: file io

2009-03-25 Thread Stephen C. Gilardi
On Mar 25, 2009, at 5:52 AM, Paul Drummond wrote: Anyone else hate the names 'slurp' and 'spit' as much as me? You're not alone there. http://groups.google.com/group/clojure/browse_frm/thread/d8064dbb94c5cd2c/bce36a47121d6faf?lnk=gst&q=slurp+name#bce36a47121d6faf IMO changing these names w

Re: file io

2009-03-25 Thread Paul Drummond
2009/3/25 e : > For example, "slurp" is, perhaps, marginally better than "read" because it > may help express that it reads the whole file. Anyone else hate the names 'slurp' and 'spit' as much as me? IMO changing these names would be a great idea whether these functions are moved up to core or

Re: file io

2009-03-24 Thread Cosmin Stejerean
On Tue, Mar 24, 2009 at 10:19 PM, e wrote: > I'm interested to know what the process/priority is on bubbling things up > from contrib into the core. Is a discussion under way about going through > it all? > > I also think it's good to have cross-language conventions sometimes unless > there are

Re: file io

2009-03-24 Thread e
I'm interested to know what the process/priority is on bubbling things up from contrib into the core. Is a discussion under way about going through it all? I also think it's good to have cross-language conventions sometimes unless there are compelling reasons. For example, "slurp" is, perhaps, m

Re: file io

2009-03-24 Thread Korny Sietsma
It'd be nice to have a macro that worked more like the first example - "spit" is great for one-liners, but the fact that it opens and closes the file each time you call it seems a bit painful for anything more complex. Something that ends up working like: (with-out-as "test.txt" (println "hello

Re: file io

2009-03-24 Thread Parth
On Mar 24, 11:53 pm, e wrote: > does anyone else think that should be more fundamental like the python > example?  imagine saying that out loud to your friend who asks . . . and the > amount of noise, visually: > > "use clojure dot contrib dot duck dash streams". > > perhaps it is already the h

Re: file io

2009-03-24 Thread e
i guess another way to say this is that I can see both sides of the argument ... on one side, it shouldn't be a priority to resolve problems that java already provides when there are probably other more pressing issues. And it's part of the design decision to allow users to leverage java libraries

Re: file io

2009-03-24 Thread e
does anyone else think that should be more fundamental like the python example? imagine saying that out loud to your friend who asks . . . and the amount of noise, visually: "use clojure dot contrib dot duck dash streams". perhaps it is already the hope that it will "spit" will eventually sit ne

Re: file io

2009-03-24 Thread Stuart Sierra
On Mar 24, 12:42 pm, Parth Malwankar wrote: > user=> (with-open [f (writer (file "test.txt"))] >          (binding [*out* f] >            (println "hello world !!!"))) Or even more simply: (use 'clojure.contrib.duck-streams) (spit "test.txt" "Hello, world!\n") -Stuart Sierra --~--~-~

Re: file io

2009-03-24 Thread Parth Malwankar
!!!"))) nil user=> % cat test.txt hello world !!! % clojure.contrib.duck-stream has an interesting set of functions. Parth > I noticed "slurp" in the api for reading ... but only the whole file at once > (read() but no readline()). Is there s

Re: file io

2009-03-24 Thread Laurent PETIT
uot;hello") > of.close() > > I checked the api and looked around the wiki and google quickly and saw how > to use java's stuff to do it ... but, welll... > > I noticed "slurp" in the api for reading ... but only the whole file at > once (read() but no

file io

2009-03-24 Thread e
ed "slurp" in the api for reading ... but only the whole file at once (read() but no readline()). Is there something symmetrical for writing (outputting)? Is there a web page called "File IO" somewhere? Thanks. --~--~-~--~~~---~--~~ You received t