read_xl question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

read_xl question

R help mailing list-2

Colleagues,

 I have a workbook which has 3 worksheets

I need to extract data from two specific cells from one ofthose worksheets.

 

I can use read_excel to do this for one file.

data<-read_excel("C:/Desktop/Excel_raw_data/0020-49785 8768.xls",

                    sheet="Flow Data",range=("b9:c10"))

 

How can I do this for all my Excel files in the directory?

 

I can get the list of Excel files using: files =list.files(pattern="*.xls")

But I’m not sure where to go from here.

Some guidance would be appreciated.

 

All the best

 Thomas Subia

Thomas Subia

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: read_xl question

Ista Zahn
Something like

files <- list.files(pattern="*.xls", full.names = TRUE)
data <- lapply(files, read_excel, sheet="Flow Data", range=("b9:c10"))

should do it.

--Ista

On Wed, Jan 23, 2019 at 12:42 PM Thomas Subia via R-help
<[hidden email]> wrote:

>
>
> Colleagues,
>
>  I have a workbook which has 3 worksheets
>
> I need to extract data from two specific cells from one ofthose worksheets.
>
>
>
> I can use read_excel to do this for one file.
>
> data<-read_excel("C:/Desktop/Excel_raw_data/0020-49785 8768.xls",
>
>                     sheet="Flow Data",range=("b9:c10"))
>
>
>
> How can I do this for all my Excel files in the directory?
>
>
>
> I can get the list of Excel files using: files =list.files(pattern="*.xls")
>
> But I’m not sure where to go from here.
>
> Some guidance would be appreciated.
>
>
>
> All the best
>
>  Thomas Subia
>
> Thomas Subia
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.