Develop program which reads data file containing information

Assignment Help Python Programming
Reference no: EM131309816

Python Programming Assignment

In this assignment you will write a program which reads a data file containing information in different formats, validates this data, and prints out a report incorporating this data. The data file contains information about a set of credit card transactions which includes the name of the purchaser, the date of the transaction, the amount of the transaction, and the credit card number. The four values for each transaction will be on a single line separated by colons. Each of these pieces of information might be entered using different possible formats, and you should be able to recognize each. Each of the possible formats are:

• Name - a first name consisting of letters, followed by a space, optionally followed by a middle initial (one letter) that may have a period after it, followed by a space, followed by a last name consisting of letters, optionally followed by a space and one of Sr, Jr, III or IV, with a period possibly after the Sr or Jr.

• Date - (1) the date can be in a text form which is made up of the name of the month, followed by a space and then the day in the month (1 or 2 digits), followed by a comma and a space, followed by the year (4 digits); (2) the date can also be in a numerical form which is made up of the month as a number between one and twelve (1 or 2 digits), followed by a / or -, followed by the day (1 or 2 digits), followed by a / or -, followed by the year (2 or 4 digits - if 2 assume the missing two digits are 20 if the existing digits are 16 or less, and 19 otherwise).

• Amount - the monetary amount is given in the format of an optional leading dollar sign, followed by the dollar amount in digits, optionally followed by a period and 2 digits representing the cents.

• Credit card number - Three types of credit cards may be used: Visa, Master Card and American Express. Each of these has a particular format: Visa numbers are 16 digits long and may be a string of 16 digits without spaces or dashes, or they can be four groups of 4 digits with a space or dash between each group, and the number begins with the digit 4; Master Card numbers have the same formatting for 16 digits, but the number begins either with a value between 51 and 55, or between 2221 and 2720; American Express numbers are 15 digits long and may be a string of 15 digits without spaces or dashes, or they can be three groups of 4, 6 and 5 digits with a space or dash between each group, and the number begins with the value 34 or 37.

Your program should take the name of a data file as a command line argument. After validating it, the data file should be read line by line. Each line should have the contents of the transaction validated and extracted using regular expressions as much as possible. If a data line contains a value that is not properly formated, an appropriate error message should be displayed about what is wrong and the data for that line should be ignored.

All data that is valid should be organized into a report in the following way: the transactions should be ordered such that those that use American Express cards come first, followed by those that use Master Card, followed by Visa. Within each credit card group, the transactions should be ordered chronologically based on the dates, with those that occur on the same date being ordered alphabetically by the person's last name, and if there are multiple transactions for the same person on that date, they should be ordered by the amount of the transaction.
As the data for a transaction is printed out in this report it should be in a standard format, not in whatever format was entered in the file.

This format is:

• Credit Card numbers are listed as separate groups of digits with spaces between them.

• Dates are listed in the format MM/DD/YYYY, where MM is a two digit form of the month, DD is a two digit form of the day, and YYYY is a four digit form of the year.

• The name is printed as the last name followed by the optional Sr., Jr., III or IV and then a comma, followed by the first name and then the optional middle initial with a period after it.

• The amount is listed as a dollar sign, followed by the dollars, and followed by a period and two digits for the cents.

You should submit your commented source code, along with the data file you used to test your program, and the corresponding report made by your program for this file.

Reference no: EM131309816

Questions Cloud

Identify and discuss potential disadvantages to organization : Use examples of real-world distributed systems and discuss how the associated organizations would benefit from the use of the systems in the short and long term. Identify and discuss potential disadvantages to the organization using the same distr..
Bonus points for either the amazon case : Analysis for up to 10 bonus points for either the Amazon case or the Netflix case.
Supply chain management within their organization : Do small companies need supply chain management within their organization?
Common mistakes made when implementing tqm : What are some common mistakes made when implementing TQM?
Develop program which reads data file containing information : In this assignment you will write a program which reads a data file containing information in different formats, validates this data, and prints out a report incorporating this data.
Importance of identifying and acknowledging : Discuss the importance of identifying and acknowledging short-term wins during change. What types of short-term wins are most meaningful? Why?
The amount of the collection float as of the end of the day : At the start of the day, the ledger balance and the available balance for ABC Company was $8,449. During the day, the firm wrote two checks in the amounts of $963 and $465. The firm deposited two checks: one check for $1,678 and another check for $67..
Organization center for disease control and prevention : Code of ethics paper, organization Center for Disease control and prevention. Is there a social responsibility for the organization in the community? Explain and provide examples
Compute the expected dividend : You are an investor in company which is an auto parts supplier. They will pay a dividend next year of $0.80 per share and are expected to grow at an annual rate of 2%. The price of the stock is currently $37.24. What is the dividend yield? Why divers..

Reviews

Write a Review

Python Programming Questions & Answers

  Create a luminance histogram

In this activity, you will create a \"luminance (grey) histogram\" for a picture # chosen by the user. A luminance histogram is created by counting how many # pixels are there for each level of luminance and then by drawing a chart (typically # a ..

  Find the number of vowels in the string

Using list and one definition for find the Number of vowels in the String.

  Project - expand the simulation with a class hierarchy

Project: Expand the Simulation with a Class Hierarchy. Purpose: Expand classes into a hierarchy. Introduce a View to the Model-View-Controller design pattern. Provide more functionality to the simulation

  Data file is a comma separated

The data file is a comma separated text values stored in a file with '.CSV' extension. The file has five columns corresponding to employee data fields listed above.

  Write a program that will input the name of five students

Write clearly with documentations where necessary as you write the program to solve the following problem.

  Function by sum of sines

code the program using an editor (DO NOT COMMAND LINE THE PROGRAM) and show the results

  Write a program that counts the frequencies of each word

Write a program that counts the frequencies of each word in a text, and output each word with its count and line numbers where it appears. We define a word as a contiguous sequence of non-white-space characters.

  Write a python program that starts from the starting state

Task consists of programming a Python implementation of a solver for the Desert Crossing Task - write a Python program that starts from the starting state.

  Assignment brief you are tasked with improving the code for

assignment brief you are tasked with improving the code for the haunted house game. please read the associated hand-out

  Interaction between the customer and the machine

In Python:Simulate a cash register or ATM including the interaction between the customer and the machine (i.e. assume that you are automating the responses)

  Write a program that reads the name of a data file

Write a program that reads the name of a data file which contains student ids (such as c1234500) and their scores. The program will find and print the average score, the number of students processed.

  Grade that will calculate and return a student''s exam

Write a function overall Grade that will calculate and return a student's 2316 exam average. It will accept five parameters, which correspond to exam1,2,3,4 and the Final grade. It should replace the lowest exam grade with the 2nd lowest exam grade

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd