Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER IN PYTHON A line from an input file has 4 fields with the following expected format: Field 1: A string that has one or

ANSWER IN PYTHON

A line from an input file has 4 fields with the following expected format: Field 1: A string that has one or more characters, none of which are double quotes. The string itself is enclosed within double quotes. Field 2: A real number with at least one digit before the decimal point with no leading zeros, and at least one digit after the decimal point. Field 3: A categorical value with the following possibilities: A, B+, B, C+, C, D Field 4: An integer between 1 and 999, no leading zeros.

Fields are separated by a comma. There may be spaces before and after a comma, and spaces around the entire line.

Here's an example:

"abcxy#$.,?PQR", 235.6614,B+,921

Write a regular expression to match and extract all 4 fields from a line of input. The extracted first field must include the surrounding double quotes characters. Assume that there will be a call re.findall that will apply your regular expression to a line string. If there are fewer or more than 4 fields, the regular expression should not match the string.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions