[erlang-questions] Read and delete file
Sat Dec 12 11:40:37 CET 2009
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:
> The file is huge so I cannot take and keep it in memory.
>> Date: Fri, 11 Dec 2009 15:44:52 +0100
>> Subject: Re: [erlang-questions] Read and delete file
>> 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
>> On Fri, 2009-12-11 at 08:50 -0500, maruthavanan s wrote:
>>> 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.
>> erlang-questions mailing list. See http://www.erlang.org/faq.html
>> erlang-questions (at) erlang.org
More information about the erlang-questions