Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
[画像:Lom/pluginfile.php/1076589/mod resource/content/1/HW4.pdf 9 AAA Invalid (AAA is not a valid letter combination) Table A Example valid/invalid sequences. Table B below shows example input file plates.txt and the corresponding expected content in the output files. plates.txt 11 A valid.txt invalid.txt 11 A OOB OOB 12 YY 222 12 YY 87652 M 500111 FA 87652 M 34091 D D 999 222 „le)&0123456 34091 D 500111 FA D 999 l©)&0123456 Table B Example input file and expected output files. Exception Handling. Your program must catch and handle exceptions where appropriate, for instance, when reading and writing files in addition to any other python runtime errors such as ValueError and IOError, including any other potential errors that may emerge from your code. /pluginfile.php/1076589/mod_resource/content/1/HW4.pdf 1) When opening file for reading an IOError may occur due to a number of reasons. Your code should display the custom message File Read Error: to indicate attempt to open the file for reading failed followed by the python error message. For example, if the input file plates.txt cannot be opened for reading then the following message may be shown: File Read Error: [Errno 2] No such file or directory: 'plates.txt Note the first message File Read Error: is the custom message and the rest is python specific error message. If the file cannot be opened for reading, then you must end the program gracefully and no further processing is required at this point. 2) When reading the lines from the input file and parsing the line to find digits and letters sequences; if the input line cannot be parsed (in other words the input line is not strictly following the required format which is two sequences separated only by white spaces) then your code should display the message Parse Error @ line number and indicate the line number which contain the line from input that does not follow the required format including the sequence found in that line. In addition to that, include any python error messages. Your code should include this line among the output to be written to invalid.txt file and proceed to processing next line in the input file. For example, when the input file plates.txt as shown in Table B above is processed, the following messages should be printed: Parse Error @ line number 2: need more than 1 value to unpack: 00B Parse Error @ line number 5: need more than 1 value to unpack: 222 Parse Error @ line number 9: need more than 1 value to unpack: l0)&0123456 Note that the above sequences are the only lines from input file in Table B that do not ]
expand button
Transcribed Image Text:Lom/pluginfile.php/1076589/mod resource/content/1/HW4.pdf 9 AAA Invalid (AAA is not a valid letter combination) Table A Example valid/invalid sequences. Table B below shows example input file plates.txt and the corresponding expected content in the output files. plates.txt 11 A valid.txt invalid.txt 11 A OOB OOB 12 YY 222 12 YY 87652 M 500111 FA 87652 M 34091 D D 999 222 „le)&0123456 34091 D 500111 FA D 999 l©)&0123456 Table B Example input file and expected output files. Exception Handling. Your program must catch and handle exceptions where appropriate, for instance, when reading and writing files in addition to any other python runtime errors such as ValueError and IOError, including any other potential errors that may emerge from your code. /pluginfile.php/1076589/mod_resource/content/1/HW4.pdf 1) When opening file for reading an IOError may occur due to a number of reasons. Your code should display the custom message File Read Error: to indicate attempt to open the file for reading failed followed by the python error message. For example, if the input file plates.txt cannot be opened for reading then the following message may be shown: File Read Error: [Errno 2] No such file or directory: 'plates.txt Note the first message File Read Error: is the custom message and the rest is python specific error message. If the file cannot be opened for reading, then you must end the program gracefully and no further processing is required at this point. 2) When reading the lines from the input file and parsing the line to find digits and letters sequences; if the input line cannot be parsed (in other words the input line is not strictly following the required format which is two sequences separated only by white spaces) then your code should display the message Parse Error @ line number and indicate the line number which contain the line from input that does not follow the required format including the sequence found in that line. In addition to that, include any python error messages. Your code should include this line among the output to be written to invalid.txt file and proceed to processing next line in the input file. For example, when the input file plates.txt as shown in Table B above is processed, the following messages should be printed: Parse Error @ line number 2: need more than 1 value to unpack: 00B Parse Error @ line number 5: need more than 1 value to unpack: 222 Parse Error @ line number 9: need more than 1 value to unpack: l0)&0123456 Note that the above sequences are the only lines from input file in Table B that do not
[画像:Task. Your task is to develop a python program that reads input from text file and finds if the alphanumeric sequence in each line of the provided input file is valid for Omani car license plate. The rules for valid sequences for car plates in Oman are as follows: Each sequence is composed of 1 to 5 digits followed by one or two letters. Digits cannot start with 0, for instance, 00, 011, or 09 are not valid digit sequences. The following list are the only valid letter combinations: ['A','AA','AB','AD','AR','AM','AW','AY', 'B','BA','BB','BD','BR','BM','BW','BY', 'D',DA','DD','DR','DW','DY', "R',RA','RR','RM','RW','RY', 'S','SS', 'M', 'MA','MB','MM','MW','MY', W',WA','WB','ww, Y,YA','YB','YD','YR','YW','YY'] Program Input/Output. Your program should read input from a file named plates.txt and write lines with valid sequences to a file named valid.txt. Any line from the input file containing invalid sequence should be written to a file named invalid.txt. Each line from the input file must be written to a separate line to the respective output files. Each line in the input file will be composed of exactly two sequences separated by any number of white spaces. Valid lines will be composed of 1 to 5 digits followed by one or more spaces followed by one or two letters without any spaces between digits or letters. Any line that does not follow this requirement may be considered invalid and included as output to file invalid.txt. after shown appropriate message as described below in the exception handling section. Table A below shows example sequences and their validity for car plates. Example Sequence Validity 12 A Valid 123 BB Valid Invalid (BZ is not a valid letter combination) Invalid (cannot start with zero digit) 10 BZ 00 R Invalid (missing digits) Invalid (more than 5 digits) MM 123456 B 1110 Y Valid Invalid (AAA is not a valid letter combination) Table A Example valid/invalid sequences. 9 AAA ]
expand button
Transcribed Image Text:Task. Your task is to develop a python program that reads input from text file and finds if the alphanumeric sequence in each line of the provided input file is valid for Omani car license plate. The rules for valid sequences for car plates in Oman are as follows: Each sequence is composed of 1 to 5 digits followed by one or two letters. Digits cannot start with 0, for instance, 00, 011, or 09 are not valid digit sequences. The following list are the only valid letter combinations: ['A','AA','AB','AD','AR','AM','AW','AY', 'B','BA','BB','BD','BR','BM','BW','BY', 'D',DA','DD','DR','DW','DY', "R',RA','RR','RM','RW','RY', 'S','SS', 'M', 'MA','MB','MM','MW','MY', W',WA','WB','ww, Y,YA','YB','YD','YR','YW','YY'] Program Input/Output. Your program should read input from a file named plates.txt and write lines with valid sequences to a file named valid.txt. Any line from the input file containing invalid sequence should be written to a file named invalid.txt. Each line from the input file must be written to a separate line to the respective output files. Each line in the input file will be composed of exactly two sequences separated by any number of white spaces. Valid lines will be composed of 1 to 5 digits followed by one or more spaces followed by one or two letters without any spaces between digits or letters. Any line that does not follow this requirement may be considered invalid and included as output to file invalid.txt. after shown appropriate message as described below in the exception handling section. Table A below shows example sequences and their validity for car plates. Example Sequence Validity 12 A Valid 123 BB Valid Invalid (BZ is not a valid letter combination) Invalid (cannot start with zero digit) 10 BZ 00 R Invalid (missing digits) Invalid (more than 5 digits) MM 123456 B 1110 Y Valid Invalid (AAA is not a valid letter combination) Table A Example valid/invalid sequences. 9 AAA
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education