簡體   English   中英

如何在沒有任何其他依賴項(例如spark,python等)的情況下將鑲木地板文件讀取為R data.frame?

[英]How to read parquet file as R data.frame without any other dependencies (like spark, python etc)?

我需要在R中讀取一些“ Parquet”文件。使用的解決方案很少

  1. sparklyr :: spark_read_parquet(需要'spark')
  2. 網狀(需要python)

現在的問題是,我不允許安裝R以外的任何其他工具。R中是否有任何可用的無需閱讀其他工具即可讀取“ paraquet”的軟件包?

您可以為此使用arrow (與Python pyarrow arrow相同),但是現在它也已打包為R使用(不需要Python)。 由於CRAN尚不可用,因此您必須先手動安裝Arrow C ++:

git clone https://github.com/apache/arrow.git
cd arrow/cpp && mkdir release && cd release

# It is important to statically link to boost libraries
cmake .. -DARROW_PARQUET=ON -DCMAKE_BUILD_TYPE=Release -DARROW_BOOST_USE_SHARED:BOOL=Off
make install

然后,您可以安裝R arrow軟件包:

devtools::install_github("apache/arrow/r")

並使用它加載Parquet文件

library(arrow)
#> 
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#> 
#>     timestamp
#> The following objects are masked from 'package:base':
#> 
#>     array, table
read_parquet("somefile.parquet", as_tibble = TRUE)
#> # A tibble: 10 x 2
#>        x       y
#>    <int>   <dbl>
#> …

編輯(22/9/2019)

現在可以在CRAN上使用,使用install.packages("arrow")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM