Python - Reading and Writing CSV and SQL from python
- Due Nov 2, 2015 by 9am
- Points 7
- Submitting a text entry box or a file upload
- File Types pdf
- Available after Oct 29, 2015 at 9am
For these questions upload a PDF with code (ideally with syntax highlighting).
1. Using python execute query from Q5, 6, and 7 in Queries 3 homework and save the results as CSVs. (3 points, one per query)
2. Execute those queries and print results out as sentences (using .format() ). That requires reaching into the row dict to identify individual fields. You do not need to transform the results of the query beyond simple formatting, so displaying month number is adequate. (3 points, one per query)
3. (1 point) Read a CSV and output it as a fixed width file. When viewed using "cat" on the command line, each column should be separated by minimum 2 spaces, the column headers should left align with their content and the headers should be divided from the content with a line made of dashes. Hint: this involves looking at maximum length of items in each column and adding spaces after the item to pad out the column. We will run your code against two different input CSVs (neither you will not see beforehand, one with have 3 columns and the other will have an unknown number of columns).
This picture shows an example (with 3 columns), get this one working first then try others. The input file is available with:
cp /home/jhowison/data_wrangling_class_files/7_csv/foundation.csv ~/