Skip to content

Instantly share code, notes, and snippets.

@elskwid
Created October 1, 2014 03:30
Show Gist options
  • Save elskwid/cb436327088d58d0e65d to your computer and use it in GitHub Desktop.
Save elskwid/cb436327088d58d0e65d to your computer and use it in GitHub Desktop.
wip data
# original data
# https://www.cisweb1.unr.edu/cxs/CourseListing.asp?master_id=1955&course_area=BASE&course_number=105&course_subtitle=00
data = File.read("data.txt")
lines = data.split("\n")
def extract_value_from_line(line, delimiter = ":")
line.split(delimiter)[1].to_s.strip
end
hash = {}
hash["course"] = extract_value_from_line(lines[0])
hash["term"] = extract_value_from_line(lines[1])
hash["section number"] = extract_value_from_line(lines[2])
hash["schedule number"] = extract_value_from_line(lines[3])
# consecutive lines
# same split token
# split()
# same index in split array
# to_s
# strip
puts hash.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment