Building flexible tools to store sums and report on CSV data (or, collections.Counter: Where have you been all my life?!)
09:45 AM - 10:45 AM on August 17, 2014, Room 704Margery Harrison
- Audience level:
- novice
- Watch:
- http://youtu.be/NWW7Sz28qZs
Description
If you're new to Python, you might find that you're using Python as if it were C. This talk will demonstrate how to take advantage of Python's special data structures to build tools for analyzing and creating nicely-formatted reports from CSV data. ("CSV" stands for "Comma Separated Values" although the term describes flat files where the fields in each row are delimited by commas, or tabs, or pipe characters, or whatever. )
Abstract
We will show how to develop code using: Lists, Sets, Tuples, Dictionaries, CSVReader, DictReader and Counter. We'll also use tuples as indexes into dictionaries, something that might not have occurred to you. And we'll show how you can use enumerate() to count how many times you've looped. (Initializing a loop-counter before and then incrementing it during the loop is just not the Python Way.)