1 of 11

CSE 163

CSVs and Lists of Dictionaries

Arpan Kapoor�Summer 2026��💭Icebreaker (discuss with neighbors): ‘

What is your favorite gloomy day activity? Add to our Slido!

slido.com

#2348882

2 of 11

Announcements

  • Programming Practice 1 due Thursday, July 2nd at 11:59pm!
  • Homework 1: Processing due Friday, July 3rd at 11:59pm!
  • Lecture problem solutions added to JupyterHub in the ‘solutions’ folder
  • No class this Friday, July 3rd! (Independence Day)
    • Enjoy the long weekend!

slido.com

#2348882

3 of 11

Dictionary Methods

dict() or {}

Makes an empty dictionary

d[key]

Gets the value for k, KeyError if None

d[key] = val

Assigns val as the value for key

d.pop(key)

Removes key from this dictionary

d.keys()

Returns a collection of the keys

d.values()

Returns a collection of the values

d.items()

Returns a collection of (key, value) tuples

slido.com

#2348882

4 of 11

Processing CSVs

  • Well structured so they are easy to parse
  • Not clear how to represent since we need info on rows and columns. Will have to use multiple data structures!
  • We will use a list of dictionaries to store this information.

slido.com

#2348882

5 of 11

Processing CSVs

5

Name,Salary

Madrona,3

Ken,1

Ryan,3

[

{'Name': 'Madrona', 'Salary': 3},

]

slido.com

#2348882

6 of 11

Processing CSVs

6

Name,Salary

Madrona,3

Ken,1

Ryan,3

[

{'Name': 'Madrona', 'Salary': 3},

{‘Name': 'Ken', 'Salary': 3},

]

slido.com

#2348882

7 of 11

Processing CSVs

7

Name,Salary

Madrona,3

Ken,1

Ryan,3

[

{'Name': 'Madrona', 'Salary': 3},

{‘Name': 'Ken', 'Salary': 3},

{‘Name': 'Ryan’, 'Salary’: 3}

]

slido.com

#2348882

8 of 11

Processing CSVs

8

Name,Salary

Madrona,3

Ken,1

Ryan,3

[

{'Name': 'Madrona', 'Salary': 3},

{‘Name': 'Ken', 'Salary': 3},

{‘Name': 'Ryan’, 'Salary’: 3}

]

0

1

2

0

1

2

slido.com

#2348882

9 of 11

Be careful of the data types!

# data is a list containing dictionaries

tas = cse163_utils.parse('tas.csv')

# tas[0] is a dictionary

madrona = tas[0]

# madrona['Salary'] is an int

madrona['Salary']

# Also works without an intermediate variable

tas[0]['Salary']

# Doesn't work! List doesn't allow string indices

tas['Salary'][0]

slido.com

#2348882

10 of 11

Lesson Recap

  • Dictionary
    • Key-value pairs. Keys are unique, values are not.
  • CSV files
    • Comma-separated values
    • Parsed as a list of dictionaries

slido.com

#2348882

11 of 11

Group Work: Best Practices

  • When working with a new group for the first time:
    • Introduce yourself!
    • If possible, angle one of your screens so that everyone can see and discuss together
    • Be respectful of each other and allow everyone to speak
  • Tips:
    • Start with making sure that everyone agrees to work on the same problem
    • Allow everyone to contribute or a chance to ask questions.
    • Ask if everyone agrees and periodically ask each other questions.
    • Call TAs or Adrian over if you need any help.
    • Don’t sit in silence.

slido.com

#2348882