1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Adding Extra Title on CSV use to_csv pandas Python [duplicate]

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 08:22.

  1. Stack

    Stack Membro Participativo

    I have a json and already converted into csv using to_csv pandas function with the header, However I want to add extra string to give extra information of the csv.

    data = [
    {
    "Attributes": "dejje",
    "Name": "Plate",
    "additionalAttributes6": "",
    "Nuber": "",
    "additionalAttributes8": "",
    "summaryDescription": "",
    "Discount": "",
    "Groups": "",
    "taxInclusive": "",
    "additionalAttributes7": ""

    }
    ]


    The below code convert it to CSV

    flatt_data = pd.json_normalize(data, max_level=1)
    flatt_data.to_csv('output.csv',mode='a',index=False, header=True, encoding=None)


    Expected Result is highlighted header

    [​IMG]

    Continue reading...

Compartilhe esta Página