2833 shaares
5 private links
5 private links
In this week's post you learned how to a command line tool that manipulates CSV files. You learned how to use the csv module to read and write CSV files, as well as how to use csv.Sniffer to automatically deduce the "dialect" of a CSV file. You also learned how to use compile and exec to run text as Python code.
My challenge to you:
Build a tool like csv-proc that allows you to filter CSV files based on some criteria. For example, if you only want to view prediabetic patients from data.csv, you could call your program like this:
$ csv-filter data.csv '100 <= float(row.glucose_mgdL) < 126'
If you enjoyed this week's post, share it with your friends and stay tuned for next week's post. See you then!