'sort row's similar columns and put row other items below the sorted row name

Sort rows names and print the corresponding values below them.

text file contains

x 1 asd
x 2 asd
x 3 asd
x 4 asd
x 5 asd
x 5 asd
x 7 asd
b 8 axy
b 9 axc

output required

x 
asd
asd
asd
asd
asd
asd
asd

b
axy
axc


Solution 1:[1]

Use csv reader

with open("file.txt", "r") as f:
    oldx, newx = '', ''
    for row in csv.reader(f, delimiter=' '):
        newx = row[0]
        if newx != oldx:
            print(newx)
            oldx = newx
        print(row[-1])

Solution 2:[2]

Try to increase the parameter value of spark.network.timeout.

spark-submit --conf spark.network.timeout 10000000 ......

Refer to spark.network.timeout

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 过过招