--20cf30434710eee45b049e1ff0eb
Content-Type: text/plain; charset=ISO-8859-1
Hi Joyce,
# First you should read the file:
alunos O.readlines('alunos.txt') # return an array with all ids
# Remove the selected id:
alunos.delete_if do |linha|
dados inha.split(":") #"quebra" quando encontrar dois pontos
outrosDados ados[0].split("!")
outrosDados login
end
# Open the file and rewrite the content
f ile.open('alunos.txt', 'w')
alunos.each |a|
f.puts a
end
f.close
This should work!
On Wed, Mar 9, 2011 at 11:55 PM, Joyce Lima <jojosl / hotmail.com> wrote:
> I'm doing one work school, sorry don't write english very good, I'm
> brasilian. I want delete only one line of File.
> I have two files and have to handle them according
> with data received by users in case some have
> Students enrolled in the following way name! id: registration.
> The user enters the id of the student, I have to search
> the file and delete the row for that id. Since there
> I found nothing specific files I'm using
> delete_if, look at the code, I'll attach it.
>
> Attachments:
> http://www.ruby-forum.com/attachment/6016/bd.rb
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
--20cf30434710eee45b049e1ff0eb--