CSV is a common file format used to represent spreadsheet data in plain-text files. Go includes an encoding/csv package that can read this format.
We’re working on a program that accepts the name of a CSV file and a column number as command-line arguments. The program should go through the file and print only the requested column.
So, for example, if you save the following data as gophers.csv:
And you run the program with pcolumn gophers.csv 2, it should output:
last_name
Pike
Thompson
Griesemer
We’ve written the printColumn function for you, which reads the specified file, prints the specified column, and returns a non-nil error value if it encounters any problems. We’ve also written a check function that will log an error an exit the program, unless the error is nil.
Your task is to update the main function to read the two command-line arguments, check that they’re valid, and use them to make an appropriate call to printColumn. We’ve added comments to main that describe what you’ll need to do.