Python Forum
Want to scrape a table data and export it into CSV format
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Want to scrape a table data and export it into CSV format
#5
(Oct-20-2019, 02:32 PM)snippsat Wrote:
(Oct-20-2019, 10:33 AM)tahir1990 Wrote: ok got it all clear.But how to export that into CSV file?
Show what you have tried.

If save to a list,then can eg use csv module.
import csv

lst = ['Alabama', 'Alaska', 'Arizona']
with open('filename.csv', 'w') as myfile:
    wr = csv.writer(myfile)
    wr.writerow(lst) 
Output:
Alabama,Alaska,Arizona
ok in order to read or write that file i saved it as usstates.csv but i am getting this error .I think i have saved that file in the wrong location.In which directory i need to save that file? I am using python 3.7.4 shell.
Traceback (most recent call last):
  File "<pyshell#23>", line 1, in <module>
    with open('usstates.csv', 'r') as csv_file:
FileNotFoundError: [Errno 2] No such file or directory: 'usstates.csv'
Reply


Messages In This Thread
RE: Want to scrape a table data and export it into CSV format - by tahir1990 - Oct-21-2019, 10:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 843 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  I am trying to scrape data to broadcast it on Telegram BarryBoos 1 2,090 Jun-10-2023, 02:36 PM
Last Post: snippsat
  Scrape table from multiple pages Nhattanktnn 1 860 Jun-07-2023, 09:35 AM
Last Post: Larz60+
  How can I target and scrape a data-stat never5000 5 2,792 Feb-11-2022, 07:59 PM
Last Post: snippsat
  Scraping data from table into existing dataframe vincer58 1 2,008 Jan-09-2022, 05:15 PM
Last Post: vincer58
  Python Obstacles | American Kenpo | Wiki Scrape URL/Table and Store it in MariaDB BrandonKastning 6 2,835 Dec-29-2021, 12:38 AM
Last Post: BrandonKastning
  Is it possible to scrape this data from Google Searches rosjo 1 2,194 Nov-06-2020, 06:51 PM
Last Post: Larz60+
  Inserting data from a table to another (in same db) firebird 5 2,479 Oct-05-2020, 06:04 AM
Last Post: buran
  Extract data from a table Bob_M 3 2,665 Aug-14-2020, 03:36 PM
Last Post: Bob_M
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,881 Aug-14-2020, 10:13 AM
Last Post: kashcode

Forum Jump:

User Panel Messages

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