A
aidy
Hi,
I am reading a txt file, e.g.
;Country Depot EmployeeID FirstName LastName UserID
null BERLIN G744ahe null Rutter 123
This is the code:
def enter_employees()
f = File.new('c:\employee_data.txt')
f.each do |line|
if !line.include? ";"
data = line.chomp.split(' ')
i = 0
while i < data.length do
if data != "null" or data != nil
puts "i = #{i}"
puts data
i += 1
end
end
end
end
end
enter_employees()
I am trying not to print to the console if data == "null", however
this is the output
i = 0
null
i = 1
BERLIN
i = 2
G744ah
i = 3
null
i = 4
Rutter
i = 5
123
Could someone tell me what I am doing wrong?
Thanks
Aidy
I am reading a txt file, e.g.
;Country Depot EmployeeID FirstName LastName UserID
null BERLIN G744ahe null Rutter 123
This is the code:
def enter_employees()
f = File.new('c:\employee_data.txt')
f.each do |line|
if !line.include? ";"
data = line.chomp.split(' ')
i = 0
while i < data.length do
if data != "null" or data != nil
puts "i = #{i}"
puts data
i += 1
end
end
end
end
end
enter_employees()
I am trying not to print to the console if data == "null", however
this is the output
i = 0
null
i = 1
BERLIN
i = 2
G744ah
i = 3
null
i = 4
Rutter
i = 5
123
Could someone tell me what I am doing wrong?
Thanks
Aidy