CSV is a file that contains a sequence of comma-separated values. One tricky part of CSV is that each cell in CSV may contain quoted commas (with double quotes). RFC4180 formalizes the specification of CSV. And your goal is to create a program that takes in a well-formed CSV file and a number N as input, and prints out only the N-th column of the CSV. Note N starts from 1, but not from 0.
The exit code of the program should be either 0 (success) or 1 (failure). In particular, the program should terminate with exit code 1 if one of the following conditions met:
- If the given CSV is not well-formed.
- If the given column number N is out of the valid range of the given CSV file. For example, when N is 0, it will exit with failure.
The program takes in two command line arguments: (1) the path to the CSV file, and (2) the column number. For example, your program written in Python should run as below:
$ python myprog.py ./csvs/mycsv.csv 2
The above command line should print out the 2nd column of the given CSV file
(mycsv.csv) if the CSV file is well-formed, and has two or more columns.
- We will send a URL link via an email.
- Visit the URL, and follow the instructions.
- We recommend you to make multiple commits, and tag your final version with a
tag name
submission. - The deadline is 23:59:59 3/7.
- You can use any programming language, e.g., bash shell script, you want.
- Does the progarm operate as expected?
- Does it follow the submission guideline?
- (Extra) We will give extra points to students who created the most concise and readable code.