【发布时间】:2021-10-05 14:57:26
【问题描述】:
我有一个数据框,其中包含一堆 .CSV 文件的名称。它在下面的 sn-p 中看起来如何:
我要做的是将这些 .CSV 中的每一个转换为一个数据框,该数据框会附加每个的结果。我要做的是根据文件名中的内容创建三个不同的数据框:
- 使用 .CSV 文件中的所有结果创建一个数据框,文件名中包含
-callers- - 使用 .CSV 文件中的所有结果创建一个数据框,文件名中包含
-results - 使用 .CSV 文件中的所有结果创建一个数据框,文件名中包含
-script_results-
如果我在下面的数据框中使用第一个 .CSV,实际将 .CSV 文件转换为数据框的命令如下所示:
data <- aws.s3::s3read_using(read.csv, object = "s3://abc-testtalk/08182020-testpilot-arizona-results-08-18-2020--08-18-2020-168701001.csv")
但我想做的是:
-
使用
s3read_using函数迭代Key下的所有.csv 文件 -
根据上面列出的文件名将它们放在三个单独的数据框中
Key 08182020-testpilot-arizona-results-08-18-2020--08-18-2020-168701001.csv 08182020-testpilot-arizona-results-08-18-2020--08-18-2020-606698088.csv 08182020-testpilot-arizona-script_results-08-18-2020--08-18-2020-114004469.csv 08182020-testpilot-arizona-script_results-08-18-2020--08-18-2020-450823767.csv 08182020-testpilot-iowa-callers-08-18-2020-374839084.csv 08182020-testpilot-maine-callers-08-18-2020-396935866.csv 08182020-testpilot-maine-results-08-18-2020--08-18-2020-990912614.csv 08182020-testpilot-maine-script_results-08-18-2020--08-18-2020-897037786.csv 08182020-testpilot-michigan-callers-08-18-2020-367670258.csv 08182020-testpilot-michigan-follow-ups-08-18-2020--08-18-2020-049435266.csv 08182020-testpilot-michigan-results-08-18-2020--08-18-2020-544974900.csv 08182020-testpilot-michigan-script_results-08-18-2020--08-18-2020-239089219.csv 08182020-testpilot-nevada-callers-08-18-2020-782329503.csv 08182020-testpilot-nevada-results-08-18-2020--08-18-2020-348644934.csv 08182020-testpilot-nevada-script_results-08-18-2020--08-18-2020-517037762.csv 08182020-testpilot-new-hampshire-callers-08-18-2020-134150800.csv 08182020-testpilot-north-carolina-callers-08-18-2020-739838755.csv 08182020-testpilot-pennsylvania-callers-08-18-2020-223839956.csv 08182020-testpilot-pennsylvania-results-08-18-2020--08-18-2020-747438886.csv 08182020-testpilot-pennsylvania-script_results-08-18-2020--08-18-2020-546894204.csv 08182020-testpilot-virginia-callers-08-18-2020-027531377.csv 08182020-testpilot-virginia-follow-ups-08-18-2020--08-18-2020-419338697.csv 08182020-testpilot-virginia-results-08-18-2020--08-18-2020-193170030.csv
【问题讨论】: