Advertisement
JAS_Software

S1

May 8th, 2021 (edited)
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. # 2_3_text_file_reader.py
  2.  
  3. import csv
  4.  
  5. # Without casting strings
  6. with open('golf_scores.csv') as csvfile:
  7.     favourites = csv.reader(csvfile, delimiter=',')
  8.     for row in favourites:
  9.         print(row)
  10.        
  11.  
  12. # With casting strings
  13. with open('golf_scores.csv', newline='') as csvfile:
  14.     favourites = csv.reader(csvfile, delimiter=',', quoting=csv.QUOTE_NONNUMERIC)
  15.     for row in favourites:
  16.         print(row)
  17.         #next line will display the variables types for the data stored in the csv file
  18.         #print(type(row[0]), type(row[1]))
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement