# CSV.read() won't accept just a file name?

**URL:** https://discourse.julialang.org/t/csv-read-wont-accept-just-a-file-name/21009
**Category:** General Usage
**Created:** [February 20, 2019, 12:46pm UTC](https://discourse.julialang.org/t/csv-read-wont-accept-just-a-file-name/21009 "2019-02-20T12:46:50Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![kirboone](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kirboone](https://discourse.julialang.org/u/kirboone)
#### Post date: [February 20, 2019, 12:46pm UTC](https://discourse.julialang.org/t/csv-read-wont-accept-just-a-file-name/21009/1 "2019-02-20T12:46:50Z")

</div>

I’m trying to load a .csv file into a DataFrame using:  
data = CSV.file(“filename.csv”) |\> DataFrame  
Where “filename.csv” exists in the same folder as my Julia program file.

According to online resources, this seems to work without problem, but Julia throws an error back that it doesn’t have a valid filename. It does work if I use “C:\documents\…\subfolder\filename.csv”, but for future applications, this won’t be acceptable when I move folders around.

What’s the appropriate naming convention/command call to make sure I only need to tell it to load a file from the same folder?

---

<div class="post-metadata">

### Author: ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)
#### Post date: [February 20, 2019, 12:50pm UTC](https://discourse.julialang.org/t/csv-read-wont-accept-just-a-file-name/21009/2 "2019-02-20T12:50:17Z")

</div>

pretty sure this should work! are you sure, that your julia is running in the right folder? check, `pwd()` … if that’s the wrong folder, you can usually fix it with `cd(@ __DIR__ )`

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [February 20, 2019, 12:59pm UTC](https://discourse.julialang.org/t/csv-read-wont-accept-just-a-file-name/21009/3 "2019-02-20T12:59:49Z")

</div>

When you refer to a file by name in julia (or python or just about any other language), the program looks for that file relative to where the julia program was run from. If you launched Julia from the cmd terminal, then thst will be whatever folder your terminal was in when you ran `julia`. If you launched Julia by clicking on an executable, then that folder will be…somewhere (I’m actually not sure where on Windows).

It sounds like what you want instead is to load a file relative to your `.jl` file (which is probably in a totally different folder from wherever you started Julia). To do that, you can use `@ __DIR__ ` to get the directory that the current file lives in. For example, you probably want to do: `CSV.read(joinpath(@ __dir__ , "filename.csv"))`

---

<div class="post-metadata">

### Author: ![kirboone](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kirboone](https://discourse.julialang.org/u/kirboone)
#### Post date: [February 20, 2019, 5:58pm UTC](https://discourse.julialang.org/t/csv-read-wont-accept-just-a-file-name/21009/4 "2019-02-20T17:58:51Z")

</div>

Yes, I’m trying to grab it from where the .jl file is located.  
`@ __DIR__ ` worked

thank you
