Texts: Name, 802.11 Specification, Memory, Price
NetEdge X12, Wi-Fi 6, 64 MiB, 199.99
StreamLink AC10, 802.11ac, 512 KiB, $89.99
AirTech XL, ax, 1 MiB, 54.99
LinkWave N2, 802.11n, 2 GiB, 149.99
WiZone 5000, Wi-Fi 5, 16 MiB, 79.99
UltraWave AC8, 802.11ac, 2048 KiB, 119.99
FastLink AC4, ac, 4 MiB, 179.99
WaveSwift X20, 802.11ax, 32 MiB, 69.99
MaxNet 8000, WiFi 6, 8 MiB, 249.99
SwiftWave AX20, ax, 2 MiB, 39.99
AirConnect X16, Wi-Fi 6, 128 MiB, 299.99
NetStream AX1, 802.11ax, 1024 MiB, 129.99
SwiftLink 400, ax, 512 KiB, 79.99
TechPro N6, 802.11n, 4 GiB, 199.99
NetWave 3000, WiFi5, 32 MiB, 109.99
AirLink AC2, 802.11ac, 4096 MiB, $149.99
MaxWave AC12, ac, 16 MiB, 229.99
StreamX AX5, 802.11ax, 8 MiB, 99.99
SwiftNet X10, Wi-Fi 6, 4 GiB, 349.99
NetLink AX3, ax, 48 MiB, 59.99
Assignment 02 ITP 107 May 26, 2023
1
Description
You are to make a Python program which reads in data from a text file and prints out a table of information based on it. Specifically, your input file contains information about Wi-Fi routers for sale. See the attached file. (Note: your code will be tested on a different file, with the same formatting) The file contains one record per line, separated by commas. The first line can be ignored, as it contains only column heading information. The columns are formatted as follows:
Name: Any string, guaranteed not to contain commas or other special characters.
802.11 Specification: Indicates which Wi-Fi standard the router supports. Your program must recognize 3 different Wi-Fi standards:
- Wi-Fi 6, also called 802.11ax or simply ax
- Wi-Fi 5, also called 802.11ac or simply ac
- Wi-Fi 4, also called 802.11n or simply n
Memory: Indicates how much RAM the router has. Numbers ending with kB or KiB are kilobytes (1024 bytes). Numbers ending with MB or MiB are megabytes (1048576 bytes). Numbers ending with GB or GiB are gigabytes (1073741824 bytes).
Price: In US dollars. Sometimes it begins with a dollar sign and sometimes it doesn't. You are permitted to store this value as a float for this assignment (though in the real world, storing monetary values in something non-exact can cause problems). Some of the fields are formatted very slightly wrong. Wi-Fi may be missing its hyphen. Some of the lowercase/uppercase letters may be wrong, so you should do your comparisons in a case-insensitive manner.
2
Output
For each of Wi-Fi 6, Wi-Fi 5, Wi-Fi 4, you are to print out a table of routers that match that particular Wi-Fi standard. Each table must be sorted, in order from cheapest router to most expensive router. You do not have to consider that 2 routers in the same class could have the same price. Prices must begin with a dollar sign. All memory capacities must be stated in kibibytes, with KiB following the number. All router names should be right-aligned. The widths of the 3 columns are, respectively, 7, 9, and 16 characters.
1/2
The following is correct output for the given input:
Wi-Fi 6 routers:
2048KiB $54.99
1024KiB $69.99
49152KiB $79.99
512KiB $99.99
8192KiB $129.99
1048576KiB $249.99
65536KiB $299.99
131072KiB $349.99
4194304KiB
AirTech XL
LinkWave N2
MaxNet 8000
NetEdge X12
NetStream AX1
SwiftLink 400
SwiftNet X10
SwiftWave AX20
WaveSwift X20
Wi-Fi 5 routers:
512KiB $79.99
16384KiB $89.99
32768KiB $109.99
2048KiB $119.99
4096KiB $149.99
16384KiB $229.99
AirLink AC2
FastLink AC4
MaxWave AC12
NetWave 3000
StreamLink AC10
UltraWave AC8
Wi-Fi 4 routers:
2097152KiB $149.99
4194304KiB $199.99
LinkWave N2
TechPro N6
3
Functional requirements
The filename for the input file must come from a command-line argument. Part of your mark comes from not writing redundant or confusing code, so it is expected that you should write at least one function. Any functions you write must have full docstrings provided (one-sentence description, parameter types described, return type described, example). Any open files must be closed as soon as they are no longer needed.