# Read data from excel starting from second row

**URL:** <https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940>\
**Category:** General Usage\
**Created:** [May 16, 2018, 8:17pm UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940 "2018-05-16T20:17:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobcvt12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobcvt12/32/2695_2.png) [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Post date:** [May 16, 2018, 8:17pm UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940/1 "2018-05-16T20:17:34Z")

</div>

I’m trying to read data in an excel workbook that starts on the second row. Using [ExcelFiles](https://github.com/davidanthoff/ExcelFiles.jl), I can I read into a dataframe if the data starts on the first row

`DataFrame(load(fname, "sheetname")`

But I’m not sure what to do when the data headers begin on the second (or later) row.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [May 16, 2018, 8:34pm UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940/2 "2018-05-16T20:34:52Z")

</div>

If you know the size of your data, you can explicitly specify the input range:

```julia
julia> DataFrame(load("test.xlsx", "Sheet1!A2:B5"))
3×2 DataFrames.DataFrame
│ Row │ test1 │ test2 │
├─────┼───────┼───────┤
│ 1 │ 1.0 │ 4.0 │
│ 2 │ 2.0 │ 5.0 │
│ 3 │ 3.0 │ 6.0 │

```

edit: looks like it might be better to use ExcelReaders.jl, which skips blank starting lines by default, or allows you to skip some number of lines:  
`readxlsheet("test.xlsx", "Sheet1", skipstartrows=1) |> DataFrame`

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [May 17, 2018, 12:12am UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940/3 "2018-05-17T00:12:00Z")

</div>

`load(fname, "sheetname")` should skip empty rows at the beginning. If not, it is a bug and it would be great if you could file an issue with a replication case.

You can also do things like `load(fname, "sheetname", skipstartrows=1)` to skip a row at the beginning. You would do that if the row actually contains stuff, i.e. if it is not blank.

The whole documentation for this is a bit in flux. I’m starting to consolidate things [here](http://www.david-anthoff.com/jl4ds/stable/fileio.html#Excel-Files-1), if you want to take a look at an early version of the new documentation.

---

<div class="post-metadata">

**Author:** ![jacobcvt12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobcvt12/32/2695_2.png) [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Post date:** [May 17, 2018, 2:18pm UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940/4 "2018-05-17T14:18:33Z")

</div>

Thanks all.

@davidanthoff This first row of my spreadsheet does have data, just not actually part of a tabular dataset, so I think this is the intended behavior. However, the `skipstartrows` keyword only works with `readxlsheet`, not `load` in my environment. Is this something that’s available in master but not version 0.3?

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [May 17, 2018, 4:39pm UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940/5 "2018-05-17T16:39:15Z")

</div>

Ah, that is a bug! Fixed on `master`, once [https://github.com/JuliaLang/METADATA.jl/pull/14692](https://github.com/JuliaLang/METADATA.jl/pull/14692) is merged it will go out widely. Thanks for reporting!

---

<div class="post-metadata">

**Author:** ![jacobcvt12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacobcvt12/32/2695_2.png) [@jacobcvt12](https://discourse.julialang.org/u/jacobcvt12)\
**Post date:** [May 17, 2018, 4:42pm UTC](https://discourse.julialang.org/t/read-data-from-excel-starting-from-second-row/10940/6 "2018-05-17T16:42:29Z")

</div>

Thanks @davidanthoff! And thanks for the great packages 🙂
