ano*_*428 3 regex glob amazon-s3 apache-spark pyspark
我有一个数字文件,每个文件都(date=yyyymmdd)
在亚马逊 s3 上按日期分隔。这些文件可以追溯到 6 个月前,但我想限制我的脚本仅使用最近 3 个月的数据。我不确定我是否能够使用正则表达式来做类似的事情sc.textFile("s3://path_to_dir/yyyy[m1,m2,m3]*")
其中 m1,m2,m3 表示从我想使用的当前日期算起的 3 个月。
一项讨论还建议使用类似的东西,sc.textFile("s3://path_to_dir/yyyym1*","s3://path_to_dir/yyyym2*","s3://path_to_dir/yyyym3*")
但这似乎对我不起作用。
是否sc.textFile( )
采用正则表达式?我知道您可以使用 glob 表达式,但我不确定如何将上述情况表示为 glob 表达式?
小智 5
For your first option, use curly braces:
sc.textFile("s3://path_to_dir/yyyy{m1,m2,m3}*")
Run Code Online (Sandbox Code Playgroud)
For your second option, you can read each single glob into an RDD and then union those RDDs into a single one:
m1 = sc.textFile("s3://path_to_dir/yyyym1*")
m2 = sc.textFile("s3://path_to_dir/yyyym2*")
m3 = sc.textFile("s3://path_to_dir/yyyym3*")
all = m1.union(m2).union(m3)
Run Code Online (Sandbox Code Playgroud)
You can use globs with sc.textFile
but not full regular expressions.
归档时间: |
|
查看次数: |
3508 次 |
最近记录: |