基本上,我想将包含GPS坐标的textFile作为textFile载入的数据输入到函数的参数中以返回特定值。我被困在通过RDD作为参数。我理解的转变和行动的概念,但我不能换我周围的头如何传递的功能,并获得纬度和经度,以作为参数传递..通过函数传递RDD
def tester(coord):
## Normally if i was iterating for the coming line
panoids = streetview.panoids(lat=coord[i][0], lon=coord[i][1])
## append the output "panoids[0]['panoid']" to the original rdd as a third element
text_file = sc.textFile("filepath")
split_data = text_file.map(lambda line:line.split(','))
print split_data.take(2) ## [[u'47.642027', u'-2.755305'], [u'47.642124', u'-2.755161']]
output = tester(split_data)
print output.take(2)
代码错字:您应该在'tester'函数内使用'coord_row',而不是'coord'。然而,这是我在我的答案建议,所以我完全同意你的解决方案:) –
感谢您注意:)现在修复它 – AbdealiJK
完美工作,我不知道我没有指出,以某种方式迭代! – MasterWizard