How to reformat the Spark Python Output

后端 未结 2 834
天命终不由人
天命终不由人 2021-01-19 04:22
(u\'142578\', (u\'The-North-side-9890\', (u\'   12457896\', 45.0)))
(u\'124578\', (u\'The-West-side-9091\', (u\'   14578217\', 0.0)))

This i got fr

2条回答
  •  心在旅途
    2021-01-19 04:52

    to get from this:

    (u'142578', (u'The-North-side-9890', (u' 12457896', 45.0)))

    to this:

    The-North-side-9890,12457896,45.0

    you need to use:

    result = result.map(lambda (k, (s, (n1, n2))): ','.join([s, str(int(n1)), str(float(n2))]))
    

提交回复
热议问题