Python Forum
Converting a patterned string or text into excel table
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting a patterned string or text into excel table
#1
Dear All,

This is my first post and im still very new to Python so i will appreciate all the patience and help i can get!

I have made a webscraper, the output of the scraper is a patterned text that I need to convert into an excel table

example of the output i got from the webscraper is:

"A" : "131", "B" :"12234", "C" : "ALPHA", "D" : "122"
"A" : "39" , "B" : "9994", "C" : "ROMEO",
"D" :"12367, "A" : "551", "B" :"13334", "C" : "BETA", "D" : "622
"A" : "679" , "B" : "4234", "C" : "XYZ",
"D" :"999"
.........etc.......

I want to convert the above output into a table as such

Output:
A B C D 131 12234 ALPHA 122 39 9994 ROMEO 12367 551 13334 BETA 662 679 4234 XYZ 999
and then feed the above table into an excel file.

Can you please advise which libraries and programming statements/codes i can use to achieve the above?

below is the code i have written so far for your reference:

from selenium import webdriver
import time

driver= webdriver.Chrome(executable_path="C:.....Desktop/chromedriver.exe")

driver.get("www.###.com")  
time.sleep(3)

driver.refresh()     #ive added a refresh statement so the links in the AJAX(XHR) can be accessed without being blocked

time.sleep(3)

driver.get ("www.###.com") 
print (driver.page_source) #this generates the output i have listed above
Best Regards,
Soup
Reply
#2
what you have is essentially a .csv file.
Double clicking on the file, and opening as an excel spreadsheet should be all you need.
If you have to do it programmatically for an assignment, it can be done using pandas, or any number of available packages, see: https://pypi.org/search/?q=excel
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Converting Pandas DataFrame to a table of hourly blocks Abedin 1 576 Apr-24-2025, 01:05 PM
Last Post: snippsat
  Formatting DateTime string and and converting it from AM/PM to 24 hours tester_V 2 1,167 Jun-08-2024, 05:16 PM
Last Post: tester_V
  trouble reading string/module from excel as a list popular_dog 0 947 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  Find a string from a column of one table in another table visedwings049 8 2,810 Sep-07-2023, 03:22 PM
Last Post: deanhystad
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 2,676 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  Color a table cell based on specific text Creepy 11 5,380 Jul-27-2023, 02:48 PM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 2,073 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  reading a table which is of type string saisankalpj 2 1,969 Dec-03-2022, 11:19 AM
Last Post: saisankalpj
  Use module docx to get text from a file with a table Pedroski55 8 18,990 Aug-30-2022, 10:52 PM
Last Post: Pedroski55
  Converting cells in excel to JSON format desmondtay 4 2,916 May-23-2022, 10:31 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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