[Python] String encoding issue in Spark SQL/DataFrame

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    So I have this csv file which has two columns: id (int), name(string). When I read the file into pyspark throught the following code:

    schema = StructType([
    StructField("id", IntegerType(), True),
    StructField("name", StringType(), True)])
    df = sqlContext.read.csv("file.csv",
    header=False, schema = schema)


    On executing df.first() I get the following output:

    Row(artistid=1240105, artistname=u'Andr\xe9 Visior')


    This is the original row from the file:

    1240105,André Visior


    How do I go about displaying the name as it is?

    Continue reading...

Compartilhe esta Página