#Create a program that can take an input and an output file and write the content of the input file into a list, the console or to the output file.
from my_modules.copy_file_content_module import copy_content
copy_content('input.txt', 'output.txt')
#Write a python file with 3 functions:
# 1. def print_file_content(file) that can print content of a text file to the console
import my_modules.io_module as io
io.print_file_content('input.txt')
# 2. def write_list_to_file(output_file, lst) that can take a list or tuple and write each element to a new line in file
lst = ['hej', 'med', 'dig']
io.write_list_to_file('list-output.txt', lst)
# create a helper function that gets an arbitrary number of strings instead of a list
io.write_strings_to_file('strings-output.txt', 'dette', 'er', 'flere', 'strings')
# 3. def read_file(input_file) that take a csv file and read each row into a list
print(io.read_file('enrollment_forecast.csv'))
['line1\n', 'line2\n', 'line3'] ['year,roll,unem,hgrad,inc', '1,5501,8.1,9552,1923', '2,5945,7,9680,1961', '3,6629,7.3,9731,1979', '4,7556,7.5,11666,2030', '5,8716,7,14675,2112', '6,9369,6.4,15265,2192', '7,9920,6.5,15484,2235', '8,10167,6.4,15723,2351', '9,11084,6.3,16501,2411', '10,12504,7.7,16890,2475', '11,13746,8.2,17203,2524', '12,13656,7.5,17707,2674', '13,13850,7.4,18108,2833', '14,14145,8.2,18266,2863', '15,14888,10.1,19308,2839', '16,14991,9.2,18224,2898', '17,14836,7.7,18997,3123', '18,14478,5.7,19505,3195', '19,14539,6.5,19800,3239', '20,14395,7.5,19546,3129', '21,14599,7.3,19117,3100', '22,14969,9.2,18774,3008', '23,15107,10.1,17813,2983', '24,14831,7.5,17304,3069', '25,15081,8.8,16756,3151', '26,15127,9.1,16749,3127', '27,15856,8.8,16925,3179', '28,15938,7.8,17231,3207', '29,16081,7,16816,3345']
# Add a functionality so that the program can be called from cli with 2 arguments
# path to input file
# an argument --file file_name to be used as the output file to write to.
# if only the input file is given write output to console
# if the input file is given with a list of extra words add those words to the output (whether to file or console)
# Add 'help' attributes to each cli argument to describe how the module is used
# see bottom of the file io_module in my_modules for answer
#Create a module called utils.py and put the following functions inside:
#first function takes a path to a folder and writes all filenames in the folder to a specified output file
# - See write_files_from_folder() in utils.py
#second takes a path to a folder and write all filenames recursively (files of all sub folders to)
# - See write_files_from_folder_and_subfolders() in utils.py
#third takes a list of filenames and print the first line of each
# - See print_first_line_from_files() in utils.py
#fourth takes a list of filenames and print each line that contains an email (just look for @)
# - See print_emails() in utils.py
#fifth takes a list of md files and writes all headlines (lines starting with #) to a file
# - See write_headlines_to_file() in utils.py
#Make sure your module can be called both from cli and imported to another module
# - See bottom of utils.py for cli test
#Create a new module that imports utils.py and test each function.
# - See utils_tester.py for import test