0

https://spark.apache.org/docs/latest/sql-getting-started.html#interoperating-with-rdds

# Load a text file and convert each line to a Row.
lines = sc.textFile("examples/src/main/resources/people.txt")
parts = lines.map(lambda l: l.split(","))
people = parts.map(lambda p: Row(name=p[0], age=int(p[1])))

This is an example on the website, but if I have thousands of columns, do I need to add the name one by one manually? like that:

airports_rdd_row = parts.map(lambda p: Row(IATA_CODE=p[0], 
                                            AIRPORT=p[1],
                                            CITY=p[2],
                                            STATE=p[3],
                                            COUNTRY=p[4],
                                            LATITUDE=p[5],
                                            LONGITUDE=p[6]
                                          ))
Trinidad
  • 211
  • 2
  • 14

0 Answers0