OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why do my all of my Openpyxl operations take so long?

  • Thread starter Thread starter Leafy
  • Start date Start date
L

Leafy

Guest
I'm manipulating data from an Excel data sheet 87MB large using Openpyxl and pandas but each one takes 10-30 minutes long.

I'm doing operations such as: deleting rows/columns, working out and printing mean, multiplying same cell in different sheets and outputting on a different sheet.

Example (took 20 minutes) :

Code:
book = 'file path' 
sheet1 = '1'  # Replace with your first sheet name
sheet2 = '2'  # Replace with your second sheet name

# Read the sheets into DataFrames
df1 = pd.read_excel(book, sheet_name=sheet1)
df2 = pd.read_excel(book, sheet_name=sheet2)

# Check if dimensions match
if df1.shape != df2.shape:
    raise ValueError("Sheets have different shapes")

I need to be able to read and write at the same time.
My end result and my operation don't need to be in an .xlsx file.
<p>I'm manipulating data from an Excel data sheet 87MB large using Openpyxl and pandas but each one takes 10-30 minutes long.</p>
<p>I'm doing operations such as: deleting rows/columns, working out and printing mean, multiplying same cell in different sheets and outputting on a different sheet.</p>
<p>Example (took 20 minutes) :</p>
<pre><code>book = 'file path'
sheet1 = '1' # Replace with your first sheet name
sheet2 = '2' # Replace with your second sheet name

# Read the sheets into DataFrames
df1 = pd.read_excel(book, sheet_name=sheet1)
df2 = pd.read_excel(book, sheet_name=sheet2)

# Check if dimensions match
if df1.shape != df2.shape:
raise ValueError("Sheets have different shapes")
</code></pre>
<p>I need to be able to read and write at the same time.<br>
My end result and my operation don't need to be in an .xlsx file.</p>
 

Latest posts

Top