Skip to content

Instantly share code, notes, and snippets.

@clofresh
Created April 22, 2010 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save clofresh/375871 to your computer and use it in GitHub Desktop.
Save clofresh/375871 to your computer and use it in GitHub Desktop.
source :in, {
:file => "../data/input/period_times.csv",
:parser => :delimited
},
[
:period,
:start_time,
:end_time
]
transform :period, :trim
before_write :check_unique, :keys => [:period]
before_write :sequence, :dest => :i
destination :decode_table, {
:file => "../data/working/period_decode.csv",
:separator => ":"
},
{
:order => [
:period,
:i
]
}
destination :out, {
:file => "../data/output/periods.csv"
},
{
:order => [
:i,
:period,
:start_time,
:end_time
]
}
source :in, {
:file => "../data/input/schedules.csv",
:parser => :delimited
},
[
:day_of_week,
:period,
:section,
:subject,
:teacher,
:location
]
rename :period, :period_id
transform :period_id, :decode, {
:decode_table_path => '../data/working/period_decode.csv',
}
rename :section, :section_id
transform :section_id, :decode, {
:decode_table_path => '../data/working/section_decode.csv'
}
rename :subject, :subject_id
transform :subject_id, :decode, {
:decode_table_path => '../data/working/subject_decode.csv'
}
rename :teacher, :teacher_id
transform :teacher_id, :decode, {
:decode_table_path => '../data/working/teacher_decode.csv'
}
transform(:location) { |name, value, row|
if value
value.downcase.strip
else
value
end
}
rename :location, :location_id
transform :location_id, :decode, {
:decode_table_path => '../data/working/location_decode.csv'
}
before_write :sequence, :dest => :i
destination :out, {
:file => "../data/output/school_schedule.csv"
},
{
:order => [
:i,
:period_id,
:day_of_week,
:period_id,
:section_id,
:subject_id,
:teacher_id,
:location_id
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment