<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create Path with OS dirname in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642844#M74607</link>
    <description>&lt;P&gt;In addition to&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/712076"&gt;@CodyPatterson&lt;/a&gt;&amp;nbsp;'s recommendation you could move on to Pythons object oriented path library called Pathlib.&amp;nbsp; I have found Pathlib more readable and robust.&amp;nbsp; Your code would look something like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pathlib import Path
import pandas as pd

os_path = Path(__file__).resolve().parent
csv_file = os_path / "AGOL_Users_ToExpire" / "UsersAboutToExpire.csv"
df_new = pd.read_csv(csv_file)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Tyler&lt;/P&gt;</description>
    <pubDate>Mon, 18 Aug 2025 13:07:09 GMT</pubDate>
    <dc:creator>TylerT</dc:creator>
    <dc:date>2025-08-18T13:07:09Z</dc:date>
    <item>
      <title>Create Path with OS dirname</title>
      <link>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642484#M74604</link>
      <description>&lt;P&gt;I can hardcode this with no issues&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CSV_FILE = r"C:\\Users\\cccc\\Desktop\\~GIS_projects\\aaaStagingProcessingScripts_dev_tst\\AGOL_User_Expire_Email\\AGOL_Users_ToExpire\\UsersAboutToExpire.csv"

df_new = pd.read_csv(CSV_FILE)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to grab the Location OA path with this&lt;/P&gt;&lt;LI-CODE lang="python"&gt;osPath = os.path.dirname(os.path.abspath(__file__))

CSV_FILE = osPath + r"\\AGOL_Users_ToExpire\\UsersAboutToExpire.csv"

df_new = pd.read_csv(CSV_FILE)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUT the layer does not work... any thoughts?&amp;nbsp; Seems like a syntax issue but cant figure it out&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 18:17:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642484#M74604</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2025-08-15T18:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create Path with OS dirname</title>
      <link>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642496#M74605</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/633156"&gt;@kapalczynski&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may want to place some debugging messages in the code to ensure that it's going to exactly what you want, try this out:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;osPath = os.path.dirname(os.path.abspath(__file__))
CSV_FILE = os.path.join(osPath, "AGOL_Users_ToExpire", "UsersAboutToExpire.csv")
print(CSV_FILE)  # Debug using this print on the csv file
df_new = pd.read_csv(CSV_FILE)&lt;/LI-CODE&gt;&lt;P&gt;There may also be an issue with your concatenation, try this out as well:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CSV_FILE = os.path.join(osPath, "AGOL_Users_ToExpire", "UsersAboutToExpire.csv")&lt;/LI-CODE&gt;&lt;P&gt;Along those lines, could you send the error that's appearing when you try to run this?&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 18:34:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642496#M74605</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2025-08-15T18:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Create Path with OS dirname</title>
      <link>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642653#M74606</link>
      <description>&lt;P&gt;1//&lt;/P&gt;</description>
      <pubDate>Fri, 15 Aug 2025 23:30:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642653#M74606</guid>
      <dc:creator>ArniMiller</dc:creator>
      <dc:date>2025-08-15T23:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create Path with OS dirname</title>
      <link>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642844#M74607</link>
      <description>&lt;P&gt;In addition to&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/712076"&gt;@CodyPatterson&lt;/a&gt;&amp;nbsp;'s recommendation you could move on to Pythons object oriented path library called Pathlib.&amp;nbsp; I have found Pathlib more readable and robust.&amp;nbsp; Your code would look something like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pathlib import Path
import pandas as pd

os_path = Path(__file__).resolve().parent
csv_file = os_path / "AGOL_Users_ToExpire" / "UsersAboutToExpire.csv"
df_new = pd.read_csv(csv_file)&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Tyler&lt;/P&gt;</description>
      <pubDate>Mon, 18 Aug 2025 13:07:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-path-with-os-dirname/m-p/1642844#M74607</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2025-08-18T13:07:09Z</dc:date>
    </item>
  </channel>
</rss>

