[erlang-questions] Read and delete file

maruthavanan s <>
Tue Dec 15 07:06:57 CET 2009


Hi,

My requirement is quite simple,

I have a large file which contains numbers and I shall take those numbers process the numbers and delete the processsed numbers. There are was where I can pause this process at certain conditions and resume when user instructs me to do so.

Regards,
Marutha

> From: 
> Date: Sat, 12 Dec 2009 02:40:37 -0800
> CC: ; 
> To: 
> Subject: Re: [erlang-questions] Read and delete file
> 
> Under Unix, there is no good way to delete a line from the front of a file.  You can truncate the file (shorten it, cutting lines off at the end), but not from the front.
> 
> If you're willing to do it all on disk (possibly with multiple copies of the data), it can be done, but it's hard to make a recommendation without knowing exactly what you're doing.
> 
> On Dec 12, 2009, at 2:18 AM, maruthavanan s wrote:
> 
> > 
> > Hi,
> > 
> > The file is huge so I cannot take and keep it in memory.
> > 
> > Regards,
> > Marutha
> > 
> >> To: 
> >> From: 
> >> CC: 
> >> Date: Fri, 11 Dec 2009 15:44:52 +0100
> >> Subject: Re: [erlang-questions] Read and delete file
> >> 
> >> Greetings,
> >> 
> >> The simplest way, if you can have the whole file in memory, would be to
> >> read all lines, handle a single line and then write all the remaining
> >> lines out to the file. Then repeat.
> >> Use file:read_file/1 (split the line from the binary) and
> >> file:write_file/2.
> >> 
> >> 
> >> bengt
> >> 
> >> On Fri, 2009-12-11 at 08:50 -0500, maruthavanan s wrote:
> >>> Hi,
> >>> 
> >>> I am opening a file using file and I read the file line by line using io:get_line.
> >>> But after reading this line I need to delete the read line from the file.
> >>> 
> >>> Appreciate you help.
> >>> 
> >>> Thanks,
> >>> Marutha
> >>> 		 	   		  
> >> 
> >> 
> >> ________________________________________________________________
> >> erlang-questions mailing list. See http://www.erlang.org/faq.html
> >> erlang-questions (at) erlang.org
> >> 
> > 		 	   		  
> 
> 
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
> 
 		 	   		  


More information about the erlang-questions mailing list