moj-analytical-services / s3tools

Interact with files in s3 on the Analytical Platform
8 stars 2 forks source link

Added support for xlsx and xls files #16

Closed willbowditch closed 7 years ago

willbowditch commented 7 years ago

Have added support for xls and xlsx files by defining s3_path_to_df() as a method. The class is determined by the file type and, if no method exists, it defaults to downloading a temp file and reporting the files location. Functions accept arguments down to the underlying readers - so you can, for example, say s3tools::s3_path_to_full_df('file.xls', sheet=2).

Also added s3tools::read_with() command that allows the user to define a custom function. s3tools:::read_using(FUN=readxl::read_excel, path="alpha-test-team/mpg.xlsx")

Test

s3tools::s3_path_to_full_df('bucket/file.xlsx')
s3tools::s3_path_to_preview_df('bucket/file.xlsx')
s3tools::s3_path_to_full_df("bucket/file.csv")
s3tools::s3_path_to_preview_df("bucket/file.csv")

s3tools:::read_using(FUN=readxl::read_excel, path="bucket/file.xlsx")