本文整理汇总了Python中pyprepbuddy.rdds.transformable_rdd.TransformableRDD.split_by_delimiter方法的典型用法代码示例。如果您正苦于以下问题:Python TransformableRDD.split_by_delimiter方法的具体用法?Python TransformableRDD.split_by_delimiter怎么用?Python TransformableRDD.split_by_delimiter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyprepbuddy.rdds.transformable_rdd.TransformableRDD
的用法示例。
在下文中一共展示了TransformableRDD.split_by_delimiter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_split_given_column_indexes_split_by_delimiter_with_retain_column
# 需要导入模块: from pyprepbuddy.rdds.transformable_rdd import TransformableRDD [as 别名]
# 或者: from pyprepbuddy.rdds.transformable_rdd.TransformableRDD import split_by_delimiter [as 别名]
def test_should_split_given_column_indexes_split_by_delimiter_with_retain_column(self):
initial_data_set = self.sc.parallelize(["FirstName LastName MiddleName,850"])
initial_rdd = TransformableRDD(initial_data_set, "csv")
split_with_retained_columns = initial_rdd.split_by_delimiter(0, " ", True)
self.assertEquals("FirstName LastName MiddleName,850,FirstName,LastName,MiddleName",
split_with_retained_columns.first())
示例2: test_should_split_the_given_column_by_delimiter_into_given_number_of_split
# 需要导入模块: from pyprepbuddy.rdds.transformable_rdd import TransformableRDD [as 别名]
# 或者: from pyprepbuddy.rdds.transformable_rdd.TransformableRDD import split_by_delimiter [as 别名]
def test_should_split_the_given_column_by_delimiter_into_given_number_of_split(self):
data = [
"John\tMale\t21\t+91-4382-313832\tCanada",
"Smith\tMale\t30\t+01-5314-343462\tUK",
"Larry\tMale\t23\t+00-9815-432975\tUSA",
"Fiona\tFemale\t18\t+89-1015-709854\tUSA"
]
initial_data_set = self.sc.parallelize(data)
initial_rdd = TransformableRDD(initial_data_set, "tsv")
new_dataset = initial_rdd.split_by_delimiter(3, "-", False, 2)
list_of_records = new_dataset.collect()
self.assertEqual(4, list_of_records.__len__())
self.assertTrue(list_of_records.__contains__("John\tMale\t21\tCanada\t+91\t4382-313832"))
self.assertTrue(list_of_records.__contains__("Smith\tMale\t30\tUK\t+01\t5314-343462"))