Last active
December 20, 2015 17:18
-
-
Save jnozsc/6167362 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: UTF-8 | |
| require 'csv' | |
| source_file = "program.csv" | |
| result_file = "result.csv" | |
| CSV.open(result_file,"ab") do |csv| | |
| csv<<['DBN', | |
| 'PROGRAM', | |
| 'PRGDESC', | |
| 'CODE', | |
| 'INTEREST', | |
| 'METHOD', | |
| 'ENG', | |
| 'MATH', | |
| 'SOC', | |
| 'SCI', | |
| 'STM', | |
| 'ELA', | |
| 'AUD', | |
| '9SEATS', | |
| '10SEATS', | |
| '9APP', | |
| '10AP', | |
| 'REQ1', | |
| 'REQ2', | |
| 'REQ3', | |
| 'REQ4', | |
| 'REQ5', | |
| 'REQ6', | |
| 'REQ7', | |
| 'REQ8', | |
| 'audgrp01', | |
| 'audgrp02', | |
| 'audgrp03', | |
| 'audgrp04', | |
| 'audgrp05', | |
| 'audgrp06', | |
| 'audgrp07', | |
| 'audgrp08', | |
| 'audgrp09', | |
| 'audgrp10', | |
| 'audgrp11', | |
| 'audgrp12', | |
| 'audgrp13', | |
| 'audgrp14', | |
| 'audgrp15', | |
| 'audgrp16', | |
| 'audgrp17', | |
| 'audgrp18', | |
| 'audgrp19', | |
| 'date01', | |
| 'date02', | |
| 'date03', | |
| 'date04', | |
| 'date05', | |
| 'date06', | |
| 'date07', | |
| 'date08', | |
| 'date09', | |
| 'date10', | |
| 'date11', | |
| 'date12', | |
| 'date13', | |
| 'date14', | |
| 'date15', | |
| 'date16', | |
| 'date17', | |
| 'date18', | |
| 'date19', | |
| 'start01', | |
| 'start02', | |
| 'start03', | |
| 'start04', | |
| 'start05', | |
| 'start06', | |
| 'start07', | |
| 'start08', | |
| 'start09', | |
| 'start10', | |
| 'start11', | |
| 'start12', | |
| 'start13', | |
| 'start14', | |
| 'start15', | |
| 'start16', | |
| 'start17', | |
| 'start18', | |
| 'start19', | |
| 'end01', | |
| 'end02', | |
| 'end03', | |
| 'end04', | |
| 'end05', | |
| 'end06', | |
| 'end07', | |
| 'end08', | |
| 'end09', | |
| 'end10', | |
| 'end11', | |
| 'end12', | |
| 'end13', | |
| 'end14', | |
| 'end15', | |
| 'end16', | |
| 'end17', | |
| 'end18', | |
| 'end19'] | |
| end | |
| CSV.foreach(source_file, :headers => true) do |row| | |
| CSV.open(result_file,"ab") do |csv| | |
| puts "processing "+row['Printed DBN'].to_s | |
| (1..10).each { |i| | |
| index = i.to_s | |
| index = '0'+index if i<10 | |
| csv << [row['Printed DBN'].to_s, | |
| row['PROGRAM'+index].to_s, | |
| row['PRGDESC'+index].to_s, | |
| row['CODE'+index].to_s, | |
| row['INTEREST'+index].to_s, | |
| row['METHOD'+index].to_s, | |
| row['ENG'+index].to_s, | |
| row['MATH'+index].to_s, | |
| row['SOC'+index].to_s, | |
| row['SCI'+index].to_s, | |
| row['STM'+index].to_s, | |
| row['ELA'+index].to_s, | |
| row['AUD'+index].to_s, | |
| row['9SEATS'+index].to_s, | |
| row['10SEATS'+index].to_s, | |
| row['9APP'+index].to_s, | |
| row['10AP'+index].to_s, | |
| row['REQ1'+index].to_s, | |
| row['REQ2'+index].to_s, | |
| row['REQ3'+index].to_s, | |
| row['REQ4'+index].to_s, | |
| row['REQ5'+index].to_s, | |
| row['REQ6'+index].to_s, | |
| row['REQ7'+index].to_s, | |
| row['REQ8'+index].to_s, | |
| row['audgrp01'].to_s, | |
| row['audgrp02'].to_s, | |
| row['audgrp03'].to_s, | |
| row['audgrp04'].to_s, | |
| row['audgrp05'].to_s, | |
| row['audgrp06'].to_s, | |
| row['audgrp07'].to_s, | |
| row['audgrp08'].to_s, | |
| row['audgrp09'].to_s, | |
| row['audgrp10'].to_s, | |
| row['audgrp11'].to_s, | |
| row['audgrp12'].to_s, | |
| row['audgrp13'].to_s, | |
| row['audgrp14'].to_s, | |
| row['audgrp15'].to_s, | |
| row['audgrp16'].to_s, | |
| row['audgrp17'].to_s, | |
| row['audgrp18'].to_s, | |
| row['audgrp19'].to_s, | |
| row['date01'].to_s, | |
| row['date02'].to_s, | |
| row['date03'].to_s, | |
| row['date04'].to_s, | |
| row['date05'].to_s, | |
| row['date06'].to_s, | |
| row['date07'].to_s, | |
| row['date08'].to_s, | |
| row['date09'].to_s, | |
| row['date10'].to_s, | |
| row['date11'].to_s, | |
| row['date12'].to_s, | |
| row['date13'].to_s, | |
| row['date14'].to_s, | |
| row['date15'].to_s, | |
| row['date16'].to_s, | |
| row['date17'].to_s, | |
| row['date18'].to_s, | |
| row['date19'].to_s, | |
| row['start01'].to_s, | |
| row['start02'].to_s, | |
| row['start03'].to_s, | |
| row['start04'].to_s, | |
| row['start05'].to_s, | |
| row['start06'].to_s, | |
| row['start07'].to_s, | |
| row['start08'].to_s, | |
| row['start09'].to_s, | |
| row['start10'].to_s, | |
| row['start11'].to_s, | |
| row['start12'].to_s, | |
| row['start13'].to_s, | |
| row['start14'].to_s, | |
| row['start15'].to_s, | |
| row['start16'].to_s, | |
| row['start17'].to_s, | |
| row['start18'].to_s, | |
| row['start19'].to_s, | |
| row['end01'].to_s, | |
| row['end02'].to_s, | |
| row['end03'].to_s, | |
| row['end04'].to_s, | |
| row['end05'].to_s, | |
| row['end06'].to_s, | |
| row['end07'].to_s, | |
| row['end08'].to_s, | |
| row['end09'].to_s, | |
| row['end10'].to_s, | |
| row['end11'].to_s, | |
| row['end12'].to_s, | |
| row['end13'].to_s, | |
| row['end14'].to_s, | |
| row['end15'].to_s, | |
| row['end16'].to_s, | |
| row['end17'].to_s, | |
| row['end18'].to_s, | |
| row['end19'].to_s] if row['PROGRAM'+index] | |
| } | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment