How can I scrape a excel file from a website and divide it in different parts

0 votes

I have to develop a program that downloads an excel file from a website in manageable chunks. Each component can only be 10MB in size, and the file extension is (.xls).

I can write various pieces of a specific size, but the characters make them worthless. I tried changing the encoding, but that didn't help either.

A code sample:

with open(file, 'wb') as f:
        for part in requests.get(website_link, stream=True).iter_content(chunk_size=10000):
             f.write(chunk)
             actual_size += 10000
             if actual_size + 10000 >= maximum_chunk_size:
                break
Jan 13, 2023 in Others by Kithuzzz
• 38,000 points
684 views

1 answer to this question.

0 votes

Use Scrapy or beautifulsoup4 parsing data it's more convenient than requests.

You can check the file size in runtime like this:

import os

file_name = "/path/to/file"

file_stats = os.stat(file_name)
size_mb = file_stats.st_size / (1024 * 1024)  # in megabytes
size_kb = file_stats.st_size / 1024  # in kilobytes
size = file_stats.st_size  # bytes
answered Jan 13, 2023 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How to scrape the specific text from kworb and extract it as an excel file?

The best practice to scrape tables is ...READ MORE

answered Feb 18, 2023 in Others by narikkadan
• 63,600 points
803 views
0 votes
1 answer

How can I open a URL in Android's web browser from my application?

ry this: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri ...READ MORE

answered Jun 14, 2022 in Others by polo
• 1,480 points
4,856 views
0 votes
1 answer

How can I find and replace text in Word using Excel VBA?

Try this code Option Explicit Const wdReplaceAll = 2 Sub ...READ MORE

answered Oct 15, 2022 in Others by narikkadan
• 63,600 points
5,018 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,468 views
0 votes
1 answer
0 votes
1 answer

How can I convert excel to PDF by Libreoffice and keep all format from excel file?

"Times New Roman" typeface does not have ...READ MORE

answered Oct 3, 2022 in Others by narikkadan
• 63,600 points
1,676 views
0 votes
1 answer

How to unmerge multiple cells and transpose each value into a new column in Pandas dataframe from excel file

Try this: df = pd.read_excel("Sample_File.xlsx", header=[0,1,2,3,4,5], index_col = ...READ MORE

answered Jan 8, 2023 in Others by narikkadan
• 63,600 points
2,595 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP