FAQ: Learn Python: Files - Reading Different Types of CSV Files

#21

Hi mtf,

I have a question, you have got in your output as separed lines like this:
[‘978-0-12-995015-8’,
‘978-1-78110-100-1’,
‘978-0-315-25137-3’,
‘978-0-388-70665-7’,…
]
my questions is, why I’ve got in one single line?
[‘978-0-12-995015-8’, ‘978-1-78110-100-1’, ‘978-0-315-25137-3’, ‘978-0-388-70665-7’,…]

Thanks for you help.

#22

Whitespace is optional, and largely ignored if the syntax is correct.

[
    value,
    value,
    value,
    value
]

is easier to read than a single line. Either form is valid.

#23

I copy the solution, reset the exercise and paste it, but it keeps giving me errors… there’s something wrong here, guys!

#24

I’m having trouble on the 3rd step: Create a DictReader instance that uses the @ symbol as a delimiter to read books_csv . Save the result in a variable called books_reader .
This is the code I have inside my with, and it is not going through:

with open('books.csv') as books_csv:
  books_reader = csv.DictReader(books_csv, delimiter = '@')
#25

I thought so too at first, but suspect they use this wording to keep users on their toes. We are still iterating through the same original csv file so its technically correct, no? Just ambiguous.