Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to import data to excel
#3
Link to Thread.
As shown bye @ibreeden,can make so it's CSV and import that to Excel.
This is the simplest way.

Can show how it's done if include Pandas as mention in other Thread.
Can save df.to_excel directly to .xlsx format.
import requests
from bs4 import BeautifulSoup
import pandas as pd

url = 'https://connectedinvestors.com/member/jonathan-kessous/friends/2'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content, 'html.parser')
record = {}
for tag in soup.find_all('div', class_="investorcard clearfix"):
    h4 = tag.find('h4')
    record[h4.a.text.strip()] = tag.attrs['id']

df = pd.DataFrame(list(record.items()), columns=['Name', 'ID'])
print(df)
df.to_excel("output.xlsx", index=False)
Output:
Name ID 0 Jonathan Kessous 454517 1 Tracy Williams 970885 2 Amanda Taylor 552089 3 Jason Stemo 1091251 4 Gerardo Marina 647958 5 Robin Bogin 377596 6 Foster Algier 311283 .....ect
In Excel:
[Image: QCHzbO.png]
Reply


Messages In This Thread
How to import data to excel - by jkessous - Jan-23-2020, 09:37 AM
RE: How to import data to excel - by ibreeden - Jan-24-2020, 12:24 PM
RE: How to import data to excel - by snippsat - Jan-24-2020, 04:01 PM
RE: How to import data to excel - by jkessous - Jan-25-2020, 07:45 PM
RE: How to import data to excel - by snippsat - Jan-26-2020, 07:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy data from Excel and paste into Discord (Midjourney) Joe_Wright 4 2,203 Jun-06-2023, 05:49 PM
Last Post: rajeshgk
  Plot a pandas data fram via pyqtgraph with an modul import and qt designer widget Nietzsche 0 886 May-29-2023, 02:42 PM
Last Post: Nietzsche
Video doing data treatment on a file import-parsing a variable EmBeck87 15 3,048 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,168 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Python 3.11 data import question love0715 2 852 Mar-05-2023, 06:50 PM
Last Post: snippsat
  Import XML file directly into Excel spreadsheet demdej 0 894 Jan-24-2023, 02:48 PM
Last Post: demdej
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,995 Dec-12-2022, 08:22 PM
Last Post: jh67
  Trying to Get Arduino sensor data over to excel using Python. eh5713 1 1,790 Dec-01-2022, 01:52 PM
Last Post: deanhystad
  Appending a row of data in an MS Excel file azizrasul 3 1,238 Nov-06-2022, 05:17 PM
Last Post: azizrasul
  Moving data from one Excel to another and finding maximum profit azizrasul 7 1,565 Oct-06-2022, 06:13 PM
Last Post: azizrasul

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020