Home > Blockchain >  Python - How to create dataFrame from this result
Python - How to create dataFrame from this result

Time:12-02

How to create a DataFrame from the result of this print?

for teste2 in Vagas:
     on_click = teste2.get('onclick')
     print(on_click)

print(on_click) returns me several of these strings below, I want to insert them into a csv file.

<input id="ctl00_ctl00_Content_Content_rpt_turno_4_ctl01_imb_vaga_1" name="ctl00$ctl00$Content$Content$rpt_turno_4$ctl01$imb_vaga_1" onclick="javascript:window.open('Cadastro.aspx?id_agenda=0&amp;id_turno=29/11/2022 3:00:00;29/11/2022 4:00:00&amp;data=29/11/2022&amp;id_turno_exportador=198397&amp;id_turno_agenda=61298&amp;id_transportadora=23213&amp;id_turno_transp=68291&amp;id_Cliente=40300&amp;codigo_terminal=40300&amp;codigo_empresa=1&amp;codigo_exportador=24978&amp;codigo_transportador=23213&amp;codigo_turno=4&amp;turno_transp_vg=68291','_blank','height=850,width=1000,top=(screen.width)?(screen.width-1000)/2 : 0,left=(screen.height)?(screen.height-700)/2 : 0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');" src="../App_Themes/SisLog/Images/add-document.gif" style="height:20px;border-width:0px;" title="Vaga disponível." type="image"/>, 

<input id="ctl00_ctl00_Content_Content_rpt_turno_6_ctl01_imb_vaga_1" name="ctl00$ctl00$Content$Content$rpt_turno_6$ctl01$imb_vaga_1" onclick="javascript:window.open('Cadastro.aspx?id_agenda=0&amp;id_turno=29/11/2022 5:00:00;29/11/2022 6:00:00&amp;data=29/11/2022&amp;id_turno_exportador=198397&amp;id_turno_agenda=61298&amp;id_transportadora=23213&amp;id_turno_transp=68291&amp;id_Cliente=40300&amp;codigo_terminal=40300&amp;codigo_empresa=1&amp;codigo_exportador=24978&amp;codigo_transportador=23213&amp;codigo_turno=6&amp;turno_transp_vg=68291','_blank','height=850,width=1000,top=(screen.width)?(screen.width-1000)/2 : 0,left=(screen.height)?(screen.height-700)/2 : 0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');" src="../App_Themes/SisLog/Images/add-document.gif" style="height:20px;border-width:0px;" title="Vaga disponível." type="image"/>,`

CodePudding user response:

You don't need a dataframe

with open('test.csv', 'a') as f:
    for item in Vagas:
        on_click = teste2.get('onclick')
        f.write(on_click '\n')

or with a dataframe:

temp=[]
for i in Vagas:
    on_click = teste2.get('onclick')
    temp.append(on_click)

df = pd.DataFrame(temp)
df.to_csv('test.csv', mode='a', header=False, index=False)
  • Related