Advertisement
homer512

dict translation

Jan 19th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. OUTPUTS = {
  3.     'Accelerator Defective\n':                                  '1\n',
  4.     'Aggressive Driving/Road Rage\n':                           '2\n',
  5.     'Alcohol Involvement\n':                                    '3\n',
  6.     'Animals Action\n':                                         '4\n',
  7.     'Backing Unsafely\n':                                       '5\n',
  8.     'Brakes Defective\n':                                       '6\n',
  9.     'Cell Phone (hand-held)\n':                                 '7\n',
  10.     'Cell Phone (hands-free)\n':                                '8\n',
  11.     'Driver Inattention/Distraction\n':                         '9\n',
  12.     'Driver Inexperience\n':                                   '10\n',
  13.     'Drugs (Illegal)\n':                                       '11\n',
  14.     'Failure to Keep Right\n':                                 '12\n',
  15.     'Failure to Yield Right-of-Way\n':                         '13\n',
  16.     'Fatigued/Drowsy\n':                                       '14\n',
  17.     'Fell Asleep\n':                                           '15\n',
  18.     'Following Too Closely\n':                                 '16\n',
  19.     'Glare\n':                                                 '17\n',
  20.     'Headlights Defective\n':                                  '18\n',
  21.     'Illness\n':                                               '19\n',
  22.     'Lane Marking Improper/Inadequate\n':                      '20\n',
  23.     'Lost Consciousness\n':                                    '21\n',
  24.     'Obstruction/Debris\n':                                    '22\n',
  25.     'Other Electronic Device\n':                               '23\n',
  26.     'Other Lighting Defects\n':                                '24\n',
  27.     'Other Vehicular\n':                                       '25\n',
  28.     'Outside Car Distraction\n':                               '26\n',
  29.     'Oversized Vehicle\n':                                     '27\n',
  30.     'Passenger Distraction\n':                                 '28\n',
  31.     'Passing or Lane Usage Improper\n':                        '29\n',
  32.     'Pavement Defective\n':                                    '30\n',
  33.     'Pavement Slippery\n':                                     '31\n',
  34.     'Pedestrian/Bicyclist/Other Pedestrian Error/Confusion\n': '32\n',
  35.     'Physical Disability\n':                                   '33\n',
  36.     'Prescription Medication\n':                               '34\n',
  37.     'Reaction to Other Uninvolved Vehicle\n':                  '35\n',
  38.     'Shoulders Defective/Improper\n':                          '36\n',
  39.     'Steering Failure\n':                                      '37\n',
  40.     'Tire Failure/Inadequate\n':                               '38\n',
  41.     'Tow Hitch Defective\n':                                   '39\n',
  42.     'Traffic Control Device Improper/Non-Working\n':           '40\n',
  43.     'Traffic Control Disregarded\n':                           '41\n',
  44.     'Turning Improperly\n':                                    '42\n',
  45.     'Unsafe Lane Changing\n':                                  '43\n',
  46.     'Unsafe Speed\n':                                          '44\n',
  47.     'Unspecified\n':                                           '45\n',
  48.     'View Obstructed/Limited\n':                               '46\n',
  49. }
  50.    
  51.  
  52. f = open('file.txt','r')
  53.  
  54. with open('output','a') as o:
  55.     for line in f:
  56.         o.write(OUTPUTS.get(line, '47\n'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement