Python Forum
Scraping Columns with Pandas (Column Entries w/ more than 1 word writes two columns)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scraping Columns with Pandas (Column Entries w/ more than 1 word writes two columns)
#1
Question 
Scraping Columns with Pandas (Column Entries w/ more than 1 word writes two columns)

My code is the following:

import pandas as pd
url = "https://en.wikipedia.org/wiki/List_of_counties_in_Alabama"
tables = pd.read_html(url) 
tables[1]
 
print(tables[1])
 
df = tables[1]
 
df.to_csv('AL_Counties.csv', sep='\t', encoding='utf-8', index=False)
Using Pandas,

Once the file is written; which works great. Any entries in any column; for instance as shown in the following screen shots in Libre Calc is writing the names into multiple columns. This makes my obstacles difficult. How do I remedy this?

Screenshot #1:

[Image: 1-2022-01-08-21-42-28.png]

Screenshot #2:

[Image: 2-2022-01-08-21-44-17.png]

Thank you everyone for this forum!
“And one of the elders saith unto me, Weep not: behold, the Lion of the tribe of Juda, the Root of David, hath prevailed to open the book,...” - Revelation 5:5 (KJV)

“And oppress not the widow, nor the fatherless, the stranger, nor the poor; and ...” - Zechariah 7:10 (KJV)

#LetHISPeopleGo

Reply


Messages In This Thread
Scraping Columns with Pandas (Column Entries w/ more than 1 word writes two columns) - by BrandonKastning - Jan-09-2022, 05:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Scraping Wikipedia Article (Name in 1 column & URL in 2nd column) ->CSV! Anyone? BrandonKastning 4 2,258 Jan-27-2022, 04:36 AM
Last Post: Larz60+
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to write 3 Columns to MariaDB? BrandonKastning 21 7,494 Mar-23-2020, 05:51 PM
Last Post: ndc85430
  Display blog posts in two columns saladgg 3 3,520 Dec-28-2018, 05:17 AM
Last Post: saladgg

Forum Jump:

User Panel Messages

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