How do I read and write CSV files with Python?

后端 未结 4 1615
抹茶落季
抹茶落季 2020-11-21 23:14

I have a file example.csv with the contents

1,\"A towel,\",1.0
42,\" it says, \",2.0
1337,is about the most ,-1
0,massively useful thing ,123
-2         


        
4条回答
  •  忘掉有多难
    2020-11-21 23:31

    import csv
    with open(fileLocation+'example.csv',newline='') as File: #the csv file is stored in a File object
    
        reader=csv.reader(File)       #csv.reader is used to read a file
        for row in reader:
            print(row)
    

提交回复
热议问题