0
import csv
with open('D:\thesis data\Experiment\COCO dataset\coco_person_dataset\annotations_download_person.csv', 'r') as f:
    reader = csv.reader(f)
    for row in reader:
         ...

FileNotFoundError: [Errno 2] No such file or directory: 'D:\thesis data\Experiment\COCO dataset\coco_person_dataset\x07nnotations_download_person.csv'

How can I remove this error? I have copied the exact path but it is still showing this error.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
  • 2
    The `\a` in your path is interpreted as a special character. Instead, either use a "raw string literal": `r"D:\thesis data\Experiment\COCO dataset\coco_person_dataset\annotations_download_person.csv"`, or escape the backslashes by doubling them: `"D:\\thesis data\\Experiment\\COCO dataset\\coco_person_dataset\\annotations_download_person.csv"`. – slothrop Jul 08 '23 at 08:44
  • Does this answer your question? [How can I put an actual backslash in a string literal (not use it for an escape sequence)?](https://stackoverflow.com/questions/3380484/how-can-i-put-an-actual-backslash-in-a-string-literal-not-use-it-for-an-escape) – slothrop Jul 08 '23 at 08:47
  • 2
    You can also use forward slashes. `'D:/thesis data/Experiment/COCO dataset/coco_person_dataset/annotations_download_person.csv'` – Burak Jul 08 '23 at 11:50

0 Answers0