[Python] SAVE PYTHON CELL OUTPUT AS A CSV FILE AFTER WEBSCRAPING [closed]

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    #this is what I am trying but it is giving me error "[​IMG] 'to_csv' #I simply want to save the scraped output as a csv file in my pc and i've performed the previous steps of scraping

    import pandas as pd
    import csv
    import numpy as np
    table = soup.find('table')
    for row in table.find_all('tr'):
    cols = row.find_all('td')
    Language_name = cols[2].getText()
    annual_average_salary = cols[3].getText()
    df = print("{},{}".format(Language_name,annual_average_salary))
    df.to_csv("popular-languages.csv")

    Continue reading...

Compartilhe esta Página