M
Mmcolli00 Mom
Please help me with this. I have been trying for days to get this right.
I don't see a next method for a hash. Just don't know what to do. Thanks
MC
Temp1.txt
----------
PersonID,PersonID
ID,ID
LastName,Social Security <need to set this val to "no valueâ€
Social Security, Address <set this key and value to Social Security..and
so on
Address,Unique ID
Unique ID,Potassium
----------
The LastName, Social Security line tells me that there is no value for
LastName and the next value in the list should be changed to the value
where Social Security instead of Address.
(my project consist of me comparing 2 files, there is more to it, but i
just wanted to explain what I am stumped on at this point.)
******************************************
File.open('Temp.txt', 'r+') do |temp|
rows = {}
temp.each_line do |line|
key, val = line.chomp.split(",",0)
rows[key] = val
#method to store first value
def storeKey(key,nextval = false)
storedKey = key
return storedKey if nextval == true
end
rows.each do |attrib|
if rows[key] != key then
@@newKey = rows[key].to_s
val1 = storeKey(@@newKey)
val2 = storeKey(@@newKey,true)
#if val == nextkey then replace with 'no value'
if rows[key] == val2 then
rows[key] = 'no value'
end
end
break
end
end
end
Attachments:
http://www.ruby-forum.com/attachment/3146/Temp1.txt
I don't see a next method for a hash. Just don't know what to do. Thanks
MC
Temp1.txt
----------
PersonID,PersonID
ID,ID
LastName,Social Security <need to set this val to "no valueâ€
Social Security, Address <set this key and value to Social Security..and
so on
Address,Unique ID
Unique ID,Potassium
----------
The LastName, Social Security line tells me that there is no value for
LastName and the next value in the list should be changed to the value
where Social Security instead of Address.
(my project consist of me comparing 2 files, there is more to it, but i
just wanted to explain what I am stumped on at this point.)
******************************************
File.open('Temp.txt', 'r+') do |temp|
rows = {}
temp.each_line do |line|
key, val = line.chomp.split(",",0)
rows[key] = val
#method to store first value
def storeKey(key,nextval = false)
storedKey = key
return storedKey if nextval == true
end
rows.each do |attrib|
if rows[key] != key then
@@newKey = rows[key].to_s
val1 = storeKey(@@newKey)
val2 = storeKey(@@newKey,true)
#if val == nextkey then replace with 'no value'
if rows[key] == val2 then
rows[key] = 'no value'
end
end
break
end
end
end
Attachments:
http://www.ruby-forum.com/attachment/3146/Temp1.txt