On Tue, Jan 6, 2009 at 4:47 PM, Tom Ayerst <tom.aye...@gmail.com> wrote:

> Its not the println, nor getting a reader (duckstreams is fine, I can do
> that). Its the converting it to a seq and stepping through it printing each
> element (which should be a line). Its the loopy, steppy bit, just for a side
> effect; that I am messing up.
>
> Cheers
>
> Tom


I've done this type of thing and it worked great for me.

       (with-open [r (clojure.contrib.duck-streams/reader "filename.txt")]
           (doseq [line (line-seq r)]
               ; do stuff with the line here
              ))

Basically you'll want to use the line-seq function.  Hopefully that helps.


> 2009/1/6 Mark Volkmann <r.mark.volkm...@gmail.com>
>
>
>> On Tue, Jan 6, 2009 at 5:26 PM, Tom Ayerst <tom.aye...@gmail.com> wrote:
>> > Hi,
>> >
>> > How do I read and print a text file?  I can read it, its the printing
>> that
>> > is the problem, I feel it should be obvious but I keep tripping myself
>> up.
>> > (The context is I need to extract data line by line, translate the line
>> > format and save it for a legacy app)
>>
>> Do you just need to print to stdout?
>> The println function does that. It puts a space between the output of
>> each of its arguments. If you don't want that you can use the str
>> function to concatenate a bunch of string values together.
>> If you need something fancier, don't forget that you can access
>> everything in java.io from Clojure.
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
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