Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: merge two files in to one file (Erik de Castro Lopo) 2. Re: merge two files in to one file (kolli kolli) 3. Re: merge two files in to one file (kolli kolli) 4. Re: merge two files in to one file (Erik de Castro Lopo) 5. Re: merge two files in to one file (kolli kolli) ---------------------------------------------------------------------- Message: 1 Date: Wed, 5 Oct 2011 12:24:57 +1100 From: Erik de Castro Lopo <mle...@mega-nerd.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <20111005122457.6b7f363644abd03d16aaf...@mega-nerd.com> Content-Type: text/plain; charset=US-ASCII kolli kolli wrote: > all the lines of first file followed by all the lines of second file Well, it can be as simple as: main :: IO () main = do data1 <- readFile "firstfile" data2 <- readFile "secondfile" writeFile "output" (data1 ++ data2) which should work fine for text files of arbitrary length. It won't however work for binary files (due to text encoding issues). For that try something like: import qualified Data.ByteString.Lazy as BSL main :: IO () main = do data1 <- BSL.readFile "firstfile" data2 <- BSL.readFile "secondfile" BSL.writeFile "output" (BSL.concat [data1, data2]) In both cases, Haskell's lazy evaluation means that the program does not need to read in the whole of each file, but will read both files in chunks as well as writing the output file in chunks. HTH, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ ------------------------------ Message: 2 Date: Tue, 4 Oct 2011 19:27:56 -0600 From: kolli kolli <nammukoll...@gmail.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <CAE7D9k46Hd-Pk=1inTiL9O=ud8wfox7yj9qlqqtjyp4vxbf...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" thanks a lot... On Tue, Oct 4, 2011 at 7:24 PM, Erik de Castro Lopo <mle...@mega-nerd.com>wrote: > kolli kolli wrote: > > > all the lines of first file followed by all the lines of second file > > Well, it can be as simple as: > > main :: IO () > main = do > data1 <- readFile "firstfile" > data2 <- readFile "secondfile" > writeFile "output" (data1 ++ data2) > > which should work fine for text files of arbitrary length. It won't > however work for binary files (due to text encoding issues). For that > try something like: > > import qualified Data.ByteString.Lazy as BSL > > main :: IO () > main = do > data1 <- BSL.readFile "firstfile" > data2 <- BSL.readFile "secondfile" > BSL.writeFile "output" (BSL.concat [data1, data2]) > > In both cases, Haskell's lazy evaluation means that the program does > not need to read in the whole of each file, but will read both files > in chunks as well as writing the output file in chunks. > > HTH, > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/811ab28b/attachment-0001.htm> ------------------------------ Message: 3 Date: Tue, 4 Oct 2011 20:10:33 -0600 From: kolli kolli <nammukoll...@gmail.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <CAE7D9k7u8jLe0y-4YvMw=0ctb+huvg6o-w8njkf-ovmjata...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" I think this(merging two files) is same as concatenating two files.. On Tue, Oct 4, 2011 at 7:24 PM, Erik de Castro Lopo <mle...@mega-nerd.com>wrote: > kolli kolli wrote: > > > all the lines of first file followed by all the lines of second file > > Well, it can be as simple as: > > main :: IO () > main = do > data1 <- readFile "firstfile" > data2 <- reFile "secondfile" > writeFile "output" (data1 ++ data2) > > which should work fine for text files of arbitrary length. It won't > however work for binary files (due to text encoding issues). For that > try something like: > > import qualified Data.ByteString.Lazy as BSL > > main :: IO () > main = do > data1 <- BSL.readFile "firstfile" > data2 <- BSL.readFile "secondfile" > BSL.writeFile "output" (BSL.concat [data1, data2]) > > In both cases, Haskell's lazy evaluation means that the program does > not need to read in the whole of each file, but will read both files > in chunks as well as writing the output file in chunks. > > HTH, > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/27c5867f/attachment-0001.htm> ------------------------------ Message: 4 Date: Wed, 5 Oct 2011 13:20:16 +1100 From: Erik de Castro Lopo <mle...@mega-nerd.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <20111005132016.b87d162de5142b393039b...@mega-nerd.com> Content-Type: text/plain; charset=US-ASCII kolli kolli wrote: > I think this(merging two files) is same as concatenating two files.. Yes, what we are doing is concatenation. I would not call this merging at all. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ ------------------------------ Message: 5 Date: Tue, 4 Oct 2011 21:08:07 -0600 From: kolli kolli <nammukoll...@gmail.com> Subject: Re: [Haskell-beginners] merge two files in to one file To: beginners@haskell.org Message-ID: <CAE7D9k7kBD2LBJzctb9=EME4m5eU8w9=cpwhjkogj0ptpiu...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" how to sort the values according to column or by date or by time or by alphabetical order * 3616 * 3556 2 11:49:43 /usr/bin/ps *3332* 2676 1 Jul 18 /usr/bin/bash *500* 2832 0 Jul 18 /usr/bin/bash On Tue, Oct 4, 2011 at 8:20 PM, Erik de Castro Lopo <mle...@mega-nerd.com>wrote: > kolli kolli wrote: > > > I think this(merging two files) is same as concatenating two files.. > > Yes, what we are doing is concatenation. I would not call this merging > at all. > > Erik > -- > ---------------------------------------------------------------------- > Erik de Castro Lopo > http://www.mega-nerd.com/ > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20111004/7b740800/attachment-0001.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 40, Issue 5 ****************************************