“CSV file does not exist” for a filename with embedded quotes

前端 未结 18 805
萌比男神i
萌比男神i 2020-12-15 23:16

I am currently learning Pandas for data analysis and having some issues reading a csv file in Atom editor.

When I am running the following code:

imp         


        
18条回答
  •  不知归路
    2020-12-16 00:00

    Sometimes we ignore a little bit issue which is not a Python or IDE fault its logical error We assumed a file .csv which is not a .csv file its a Excell Worksheet file have a look



    When you try to open that file using Import compiler will through the error have a look

    To Resolve the issue

    open your Target file into Microsoft Excell and save that file in .csv format it is important to note that Encoding is important because it will help you to open the file when you try to open it with

    with open('YourTargetFile.csv','r',encoding='UTF-8') as file:
    

    So you are set to go now Try to open your file as this

    import csv
    with open('plain.csv','r',encoding='UTF-8') as file:
    load = csv.reader(file)
    for line in load:
        print(line)
    

    Here is the Output

提交回复
热议问题