Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 1.75 KB

File metadata and controls

44 lines (34 loc) · 1.75 KB

02/28 Activity

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:

  1. If the given CSV is not well-formed.
  2. 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.

Command-Line Interface

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.

Submission Guideline

  1. We will send a URL link via an email.
  2. Visit the URL, and follow the instructions.
  3. We recommend you to make multiple commits, and tag your final version with a tag name submission.
  4. The deadline is 23:59:59 3/7.
  5. You can use any programming language, e.g., bash shell script, you want.

Grading Criteria

  1. Does the progarm operate as expected?
  2. Does it follow the submission guideline?
  3. (Extra) We will give extra points to students who created the most concise and readable code.