M03 - Read Files Flashcards

1
Q

IndentationError

A

Cause: did not indent code after a colon

Solution: indent code after colon that should run as the block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SyntaxError

A

Possible Cause: no colon at the end of statement where one should be

Solution: find and add colon

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

reader( ) function syntax

A

file_reader_variable = csv.reader(file_variable/alias given using with or open( ))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

next( ) syntax to print header row

A
# Read file w/ reader function
file_reader = csv.reader(file_alias)
#Print header row
headers = next(file_reader)
# Prints the first row
print(headers)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

next( ) what it does

A

Skips first row and returns next item in list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly