# Relative path to file

**URL:** <https://discourse.julialang.org/t/relative-path-to-file/24114>\
**Category:** General Usage\
**Created:** [May 11, 2019, 4:27pm UTC](https://discourse.julialang.org/t/relative-path-to-file/24114 "2019-05-11T16:27:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)\
**Post date:** [May 11, 2019, 4:27pm UTC](https://discourse.julialang.org/t/relative-path-to-file/24114/1 "2019-05-11T16:27:29Z")

</div>

I’m working in a model with Julia that extracts some data from a spreadsheet. Everything works fine, but I’d like to read the spreadsheet into Julia using a relative path, to be able to run the Julia file from different machines.

I’m using the `XLSX.readdata()` function. The JL and the XLSX files are together in the same folder.

Is there any way to do this in Julia?

Thank you in advance for any help!

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [May 11, 2019, 5:36pm UTC](https://discourse.julialang.org/t/relative-path-to-file/24114/2 "2019-05-11T17:36:16Z")

</div>

> [@dg.aragones](#):
>
> Is there any way to do this in Julia?

Definitely! What have you tried? Will the file always be in the same folder as the script, do you want to give the path as a command line argument?

See [Filesystem · The Julia Language](https://docs.julialang.org/en/v1/base/file/index.html)

---

<div class="post-metadata">

**Author:** ![dg.aragones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dg.aragones/32/11275_2.png) [@dg.aragones](https://discourse.julialang.org/u/dg.aragones)\
**Post date:** [May 12, 2019, 4:29pm UTC](https://discourse.julialang.org/t/relative-path-to-file/24114/3 "2019-05-12T16:29:56Z")

</div>

Thank you for your response!

I have tried using an absolute path and it works fine. The problem comes when I want to run it on a different machine, where I need to change the path to the file.

The idea is that the XLSX file will always be in the same folder together with the JL file.

I have seen the documentation, but still I don’t know how to do it.

---

<div class="post-metadata">

**Author:** ![Rudi79](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rudi79/32/3884_2.png) [@Rudi79](https://discourse.julialang.org/u/Rudi79)\
**Post date:** [May 12, 2019, 7:05pm UTC](https://discourse.julialang.org/t/relative-path-to-file/24114/4 "2019-05-12T19:05:35Z")

</div>

Look at [`https://docs.julialang.org/en/v1/base/file/#Base.@ __DIR__ `](https://docs.julialang.org/en/v1/base/file/#Base.@ __DIR__ )

---

<div class="post-metadata">

**Author:** ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Post date:** [May 12, 2019, 10:52pm UTC](https://discourse.julialang.org/t/relative-path-to-file/24114/5 "2019-05-12T22:52:03Z")

</div>

As @Rudi79 said, try this:

```julia
filename = "whatever.xlsx"
filepath = joinpath(@ __DIR__ , filename)
println(filepath)

```
