From: "Jesús Gabriel y Galán" Date: 2010-11-16T04:08:29+09:00 Subject: Re: please help load from txt 2010/11/15 Jesús Gabriel y Galán : > On Mon, Nov 15, 2010 at 7:47 PM, Lark Work wrote: >> thanks for your help, but i got that already i don't think you quit >> understand me > > Sorry about that. Let's try to move forward then: > >>  because i want to call just one line of at the time this >> is how data.txt looks like > > I have problems understanding what you mean by "call". > >> hisname,lastname,callname,age >> otherperson,lastname,callname,age >> etc >> >> i wan't it to work like a a database of datas of persons and i want to >> call one person at the time is that posible??? > > Here I don't understand what you mean by "call" and "at the time". If > you want it to work like a database of persons, then you would like to > load the data into a data structure that supports containing the list > of persons, and querying by some key, for example, the name. Is that > something that makes sense? I don't have time right now, but I'll come > back later with an example of what I mean. Got a couple of minutes: Person = Struct.new :name,:last_name,:call_name,:age class PersonList attr_reader :persons def initialize file @persons = {} File.foreach(file) do |line| name, *rest_of_data = line.chomp.split(",") @persons[name] = Person.new(name, *rest_of_data) end end end person_list = PersonList.new("data2.txt") p person_list.persons["name"] I tried with this file: name,lastname,callname,age name2,lastname2,callname2,age2 and got: $ ruby persons.rb # Jesus.