a = ['0,Italy,"Aromas include tropical fruit, broom, brimstone and dried herb. The palate isnt overly expressive, offering unripened apple, citrus and dried sage alongside brisk acidity.",Vulkà Bianco,87,,Sicily & Sardinia,Etna,,Kerin O’Keefe,@kerinokeefe,Nicosia 2013 Vulkà Bianco (Etna),White Blend,Nicosia']
我有这个列表,我只想将粗体字符串分隔符从“,”改为“#”。你知道吗
这会得到所需的输入:
但有些东西告诉我这不是很有用/一般。你知道吗
但无论如何,解决这类问题的方法可能会涉及以下两种字符串/列表方法:
split
和replace
https://docs.python.org/3/library/stdtypes.html#str.split
https://docs.python.org/3/library/stdtypes.html#str.replace
更新
因此,如果需要使用spark RDD,可以首先使用字符串列表(还不是csv)创建RDD
我有几个假设,因为您只提供了一个示例行。你知道吗
这些假设是关于这个双引号字符串
" "
的存在,它是需要替换的带有逗号的列。你知道吗此外,我假设在其他任何列中都没有
"
。你知道吗我还假设这个列在处理之后不需要这些
"
。你知道吗解释
rdd
方法map
将函数映射到RDD中的每一行,并且map
获取的lambda返回新行。所以在这里,我将这个替换命令链映射到RDD中的每一行(然后在示例中,我take
一行)相关问题 更多 >
编程相关推荐