这是我在scala文件中的代码
val data = List("cdn.resized-images.covethome.com")
val dataRDD = sc.makeRDD(data)
val scriptPath = "/Users/hareshbhuriya/Documents/final-python-integration/web_domain_cleansing.py"
val result = dataRDD.pipe(scriptPath)
我正在使用python文件读取该字符串
for line in sys.stdin:
output = sample_function(line)
print(output)
这里python文件的输出是pandas dataFrame,我想在调用管道函数的scala文件中获取它。
如果我直接将字符串作为line
传递,而不是将cdn.resized-images.covethome.com
作为参数传递给sample_function,我将获得所需的输出。
喜欢这个
for line in sys.stdin:
output = sample_function("cdn.resized-images.covethome.com")
print(output)
但是我想动态传递字符串。我应该如何处理/处理来自sys.stdin的字符串?请帮助
我需要使用line.rstrip()
,然后一切正常。谢谢。