Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me generating a python code for the assignment: In this assignment, you will play the role of a data engineer at a manufacturing
Please help me generating a python code for the assignment:
In this assignment, you will play the role of a data engineer at a manufacturing company. The company
has a legacy system that stores logs of manufacturing batches in a peculiar string format. Your task is to
validate and extract information from these log strings.
A valid log string adheres to the following format:
Batch Prefix: Each batch within the string starts with the prefix case sensitive
Batch ID: Following the prefix, there is a batch ID consisting of exactly four digits.
Product Code: Next, there is a product code that starts with case sensitive followed by
exactly two letters uppercase case sensitive
Quantity: Then, there is a quantity section that starts with case sensitive followed by an
integer above zero representing the quantity of products in the batch. Leading zeros are ok For
example, Q is OK and is OK However, the leading zero should be eliminated once the
quantity number is extracted. For example, is once extracted. Note that the quantity
output is an integer, not a string.
Date: Finally, there is a date section that starts with Dcase sensitive followed by a date in the
format YYYYMMDD
Its YYYYMMDD length should be eight characters.
The first four characters represent the year, which should be between and
The next two characters represent the month, which should be between and
The last two characters represent the day, which should be between and although
not all months have days, we'll ignore this detail for simplicity no need to check for
leap year. For example, is ok is ok
The string can contain multiple batches, each adhering to the format described above.
Your task is to write a Python function that takes this log string as input and returns a list of dictionaries
containing information about each batch if the string is valid. If the string is invalid, return "invalid". The
"invalid" return value is a string value, not a Boolean value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started