Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in Python (no imports) def combine_info(files_lst, file_out): month_dict = { '01': 'Jan', '02': 'Feb', '03': 'Mar', '04': 'Apr', '05': 'May', '06': 'Jun',

Please answer in Python (no imports)

def combine_info(files_lst, file_out): month_dict = { '01': 'Jan', '02': 'Feb', '03': 'Mar', '04': 'Apr', '05': 'May', '06': 'Jun', \ '07': 'Jul', '08': 'Aug', '09': 'Sep', '10': 'Oct', '11': 'Nov', '12': 'Dec'} return None

Directions: - This function takes two parameters: files_lst, a list of paths to .txt files (as a list of strings); file_out, a path to another file to output. - This function reads all files from the list, and modifies some of information then writes all the information to the output file and returns nothing. - Modifications: convert the date of birth from the DD/MM/YYYY format to "month DD YYYY"" (08/09/2003 to August 9 2003) - Information that should be written in the output file: 1. File header: name,city,DOB 2. On each line: name, city, modified date of birth

Doctests: >>> lst_1 = ['files/info_1.txt','files/info_3.txt', 'files/info_4.txt'] >>> combine_info(lst_1, 'files/combined_1_out.txt') >>> with open('files/combined_1_out.txt', 'r') as outfile1: ... for line in outfile1: ... print(line.strip()) name,city,DOB Rob,Chicago,Oct 10 2010 Ella,New York,Apr 09 1970 Mary,New York.,Jan 01 2004 Sue,San Diego,Mar 19 2015 Ben,London,Dec 08 1970 Kate,Paris,Jul 13 1945

>>> lst_2 = ['files/info_2.txt','files/header.txt'] >>> combine_info(lst_2, 'files/combined_2_out.txt') >>> with open('files/combined_2_out.txt', 'r') as outfile2: ... for line in outfile2: ... print(line.strip()) name,city,DOB Rob,Chicago,Oct 10 2010 Ezra,London,Apr 12 1978 Mary,Paris,Sep 11 1975 Ron,paris,Nov 11 2002 Harry,paris,Dec 15 2002

Example file: Name, City, DOB Rob, Chicago, 10/10/2010 Ella, New York, 04/09/1970 Mary, New York. , 01/01/2004

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions