[Python] FileNotFoundError: [Errno 2] No such file or directory: 'Test.csv' in VS Code

Discussão em 'Python' iniciado por Stack, Setembro 6, 2025.

  1. Stack

    Stack Membro Participativo

    I was trying to read from a .csv file and wrote a very basic code.

    import csv

    with open('Test.csv', 'r') as csv_file:
    csv_reader = csv.reader(csv_file)

    for line in csv_reader:
    print(line)


    Both the test.csv and my .py file is in the same directory. For some reason when I run this in vs code, it pops up an error:


    FileNotFoundError: [Errno 2] No such file or directory: 'Test.csv'
    ​

    But the same code works perfectly fine with sublime text. I'd like to use Vs code for my future projects so it will be helpful if someone can solve this issue. Thank you.

    Continue reading...

Compartilhe esta Página