{
  "id": 45824,
  "title": "Reading from a Windows directory (\\ back-slash)",
  "url": "/competitions/tensorflow-speech-recognition-challenge/discussion/45824",
  "author_name": "",
  "post_date": "2017-12-16T07:25:14.406122200Z",
  "votes": null,
  "comment_count": 4,
  "views": 0,
  "content": "<p>How can I read from a Windows path? <strong>train.z</strong> was extracted in Windows 10, and only the folder containing the word \"down\" was uploaded.</p>\n\n<p>When I click in the \"Input Files\" list, the path to the file is as shown below</p>\n\n<pre><code>file_path = '../input/trainDown/audio\\down/1cbcc7a7_nohash_0.wav'\n</code></pre>\n\n<p>The line below gives an error</p>\n\n<pre><code>amplitudes, sample_rate = librosa.load(str(file_path), sr=None)\n</code></pre>\n\n<p>FileNotFoundError: [Errno 2] No such file or directory: '/kaggle/input/trainDown/audio\\down/1cbcc7a7_nohash_0.wav'</p>",
  "messages": [
    {
      "id": "258477",
      "postDate": "12/16/2017 07:25:14",
      "content": "<p>How can I read from a Windows path? <strong>train.z</strong> was extracted in Windows 10, and only the folder containing the word \"down\" was uploaded.</p>\n\n<p>When I click in the \"Input Files\" list, the path to the file is as shown below</p>\n\n<pre><code>file_path = '../input/trainDown/audio\\down/1cbcc7a7_nohash_0.wav'\n</code></pre>\n\n<p>The line below gives an error</p>\n\n<pre><code>amplitudes, sample_rate = librosa.load(str(file_path), sr=None)\n</code></pre>\n\n<p>FileNotFoundError: [Errno 2] No such file or directory: '/kaggle/input/trainDown/audio\\down/1cbcc7a7_nohash_0.wav'</p>",
      "rawMarkdown": "How can I read from a Windows path? **train.z** was extracted in Windows 10, and only the folder containing the word \"down\" was uploaded.\n\nWhen I click in the \"Input Files\" list, the path to the file is as shown below\n\n    file_path = '../input/trainDown/audio\\down/1cbcc7a7_nohash_0.wav'\n\nThe line below gives an error\n\n    amplitudes, sample_rate = librosa.load(str(file_path), sr=None)\n\n\nFileNotFoundError: [Errno 2] No such file or directory: '/kaggle/input/trainDown/audio\\\\down/1cbcc7a7_nohash_0.wav'",
      "votes": null
    },
    {
      "id": "258555",
      "postDate": "12/16/2017 12:10:49",
      "content": "<p>May the mix of forward and backslash? Typically in multiplatform applications the \\ has to be escaped as \\\\. For instance in R, both options work: input\\\\file.csv and input/file.csv, but only because the Windows version of R replaces / for \\ (which is what Windows expects.).</p>",
      "rawMarkdown": "May the mix of forward and backslash? Typically in multiplatform applications the \\ has to be escaped as \\\\\\\\. For instance in R, both options work: input\\\\\\\\file.csv and input/file.csv, but only because the Windows version of R replaces / for \\\\ (which is what Windows expects.).",
      "votes": null
    },
    {
      "id": "258755",
      "postDate": "12/17/2017 00:32:37",
      "content": "<p>Thanks. I tried many \"escape\" variations. \"...\\down...\", \"\\down\", \"/down\", \"/\\down\" and \"/\\down\" did not work. Fortunately, only the predictions have to be submitted, not the code.</p>",
      "rawMarkdown": "Thanks. I tried many \"escape\" variations. \"...\\down...\", \"\\\\down\", \"/down\", \"/\\\\down\" and \"/\\down\" did not work. Fortunately, only the predictions have to be submitted, not the code.",
      "votes": null
    },
    {
      "id": "259491",
      "postDate": "12/18/2017 14:04:23",
      "content": "<p>try the following:\nfile_path = r '../input/trainDown/audio/down/1cbcc7a7_nohash_0.wav'\nUse the symbol \"r\" in the beginning to interpret it as a string. I think it should work.</p>",
      "rawMarkdown": "try the following:\nfile_path = r '../input/trainDown/audio/down/1cbcc7a7_nohash_0.wav'\nUse the symbol \"r\" in the beginning to interpret it as a string. I think it should work.",
      "votes": null
    },
    {
      "id": "260704",
      "postDate": "12/20/2017 18:52:51",
      "content": "<p>I used this code in windows to find all the wav files in a folder</p>\n\n<p>import os</p>\n\n<p>[os.path.join(path, f) for (path, directorynames, filenames) in os.walk(\"..\\\\Data\\\\train\\\\audio\\\\_background_noise_\") \n                     for f in filenames if f.endswith(\".wav\")]</p>\n\n<p>which gave me filenames that tf.read_file was able to parse correctly.</p>",
      "rawMarkdown": "I used this code in windows to find all the wav files in a folder\n\nimport os\n\n[os.path.join(path, f) for (path, directorynames, filenames) in os.walk(\"..\\\\\\\\Data\\\\\\\\train\\\\\\\\audio\\\\\\\\_background_noise_\") \n                     for f in filenames if f.endswith(\".wav\")]\n\nwhich gave me filenames that tf.read_file was able to parse correctly.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 258555,
      "author_name": "batangas",
      "author_url": "",
      "post_date": "12/16/2017 12:10:49",
      "content": "<p>May the mix of forward and backslash? Typically in multiplatform applications the \\ has to be escaped as \\\\. For instance in R, both options work: input\\\\file.csv and input/file.csv, but only because the Windows version of R replaces / for \\ (which is what Windows expects.).</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 258755,
      "author_name": "rockp1",
      "author_url": "",
      "post_date": "12/17/2017 00:32:37",
      "content": "<p>Thanks. I tried many \"escape\" variations. \"...\\down...\", \"\\down\", \"/down\", \"/\\down\" and \"/\\down\" did not work. Fortunately, only the predictions have to be submitted, not the code.</p>",
      "votes": null,
      "replies": [
        {
          "id": 260704,
          "author_name": "altourus",
          "author_url": "",
          "post_date": "12/20/2017 18:52:51",
          "content": "<p>I used this code in windows to find all the wav files in a folder</p>\n\n<p>import os</p>\n\n<p>[os.path.join(path, f) for (path, directorynames, filenames) in os.walk(\"..\\\\Data\\\\train\\\\audio\\\\_background_noise_\") \n                     for f in filenames if f.endswith(\".wav\")]</p>\n\n<p>which gave me filenames that tf.read_file was able to parse correctly.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 259491,
      "author_name": "anasvaf",
      "author_url": "",
      "post_date": "12/18/2017 14:04:23",
      "content": "<p>try the following:\nfile_path = r '../input/trainDown/audio/down/1cbcc7a7_nohash_0.wav'\nUse the symbol \"r\" in the beginning to interpret it as a string. I think it should work.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "258477": "How can I read from a Windows path? **train.z** was extracted in Windows 10, and only the folder containing the word \"down\" was uploaded.\n\nWhen I click in the \"Input Files\" list, the path to the file is as shown below\n\n    file_path = '../input/trainDown/audio\\down/1cbcc7a7_nohash_0.wav'\n\nThe line below gives an error\n\n    amplitudes, sample_rate = librosa.load(str(file_path), sr=None)\n\n\nFileNotFoundError: [Errno 2] No such file or directory: '/kaggle/input/trainDown/audio\\\\down/1cbcc7a7_nohash_0.wav'",
    "258555": "May the mix of forward and backslash? Typically in multiplatform applications the \\ has to be escaped as \\\\\\\\. For instance in R, both options work: input\\\\\\\\file.csv and input/file.csv, but only because the Windows version of R replaces / for \\\\ (which is what Windows expects.).",
    "258755": "Thanks. I tried many \"escape\" variations. \"...\\down...\", \"\\\\down\", \"/down\", \"/\\\\down\" and \"/\\down\" did not work. Fortunately, only the predictions have to be submitted, not the code.",
    "259491": "try the following:\nfile_path = r '../input/trainDown/audio/down/1cbcc7a7_nohash_0.wav'\nUse the symbol \"r\" in the beginning to interpret it as a string. I think it should work.",
    "260704": "I used this code in windows to find all the wav files in a folder\n\nimport os\n\n[os.path.join(path, f) for (path, directorynames, filenames) in os.walk(\"..\\\\\\\\Data\\\\\\\\train\\\\\\\\audio\\\\\\\\_background_noise_\") \n                     for f in filenames if f.endswith(\".wav\")]\n\nwhich gave me filenames that tf.read_file was able to parse correctly."
  },
  "source": "meta"
}