[英]How to filter out lines starting with 'URL' in filter pyspark RDD
[英]Pyspark filter empty lines from RDD not working
我對火花和pyspark來說相對較新
final_plogfiles = plogfiles.filter(lambda x: len(x)>0)
我編寫了這段代碼來過濾掉RDD plogfiles中的空行。 它沒有刪除空行。
我也試過了
plogfiles.filter(lambda x: len(x.split())>0)
但是,如果我使用plogfiles.filter(lambda x: x.split())
,所有行中的尾隨和前導空格都會被修剪
我只想過濾掉空行。 我想知道我哪里出錯了。
plogfiles是RDD嗎? 以下工作對我來說很好:
lines = sc.textFile(input_file)
non_empty_lines = lines.filter(lambda x: len(x)>0 )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.