[Python] Formatting csv file format in pyspark

Discussão em 'Python' iniciado por Stack, Maio 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have a | delimited csv file with data as shown below.

    [​IMG]

    However, when the data is read from csv into a data frame, the dataframe output is as below:

    |Name|Age|Address|Occupation|
    |Tom|20|Houston Texas USA|Doctor|
    |Brad|21|Austin Texas USA|Chef|
    |Harry|22|Chicago|NULL|
    |Illinois|NULL|NULL|NULL|
    |USA|Student|NULL|NULL|


    [​IMG]

    How can I read the data in pyspark in proper format where the data can be written in table as shown below

    [​IMG]

    Continue reading...

Compartilhe esta Página