を含む行をカウント:PySparkが、私はこのような何かを見て、複数のxmlファイルを持っている文字列
<?xml version="1.0" encoding="UTF-8"?>
<parent>
<row AcceptedAnswerId="15" AnswerCount="5" Body="<p>How should
I elicit prior distributions from experts when fitting a Bayesian
model?</p> " CommentCount="1" CreationDate="2010-07-
19T19:12:12.510" FavoriteCount="17" Id="1" LastActivityDate="2010-09-
15T21:08:26.077" OwnerUserId="8" PostTypeId="1" Score="26"
Tags="<bayesian><prior><elicitation>"
Title="Eliciting priors from experts" ViewCount="1457" />
私は、文字列を含まない行をカウントするPySparkを使用できるようにしたいと思います:<row
私の現在の考え:
def startWithRow(line):
if line.strip().startswith("<row"):
return True
else:
return False
sc.textFile(localpath("folder_containing_xmg.gz_files")) \
.filter(lambda x: not startWithRow(x)) \
.count()
私はこれを検証してみましたが、私は、XMLをダウンロード(意味を持たなくても、単純なカウントラインから結果を取得していますファイルにはwc
がありますが、これはPySparkの単語数に一致しませんでした。)
私のアプローチに関する何かが間違った/奇妙なものとして目立つのですか?
の可能性のある重複した[ApacheのスパークでXMLファイルを解析する方法?](https://stackoverflow.com/questions/33280821/how-to-parse-xml-files-in-apache-spark) –