本文整理匯總了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"))