Coder Social home page Coder Social logo

Sheets API erroneously rejects new rowCount if (new rowCount * old columnCount) > 5000000 (was: Bug in the number of cells of the dataframe about gspread-dataframe HOT 4 CLOSED

robin900 avatar robin900 commented on May 23, 2024
Sheets API erroneously rejects new rowCount if (new rowCount * old columnCount) > 5000000 (was: Bug in the number of cells of the dataframe

from gspread-dataframe.

Comments (4)

robin900 avatar robin900 commented on May 23, 2024 1

@devironl So I discovered the cause of your initially reported bug: If you submit to the Sheets API a request to change both a worksheet's rowCount and columnCount, the Sheets API does the following:

  1. Using the new rowCount value and the existing columnCount value, calculates whether rowCount * columnCount > 5000000. If the cell count limit is exceeded, a 400 response is returned.
  2. Using the new rowCount and new columnCount values, calculate whether rowCount * columnCount > 5000000. If the cell count limit is exceeded, a 400 response is returned.
  3. Otherwise, apply the changes to rowCount and columnCount and return a 200 response.

Your particular case -- of wanting rows=200000 and cols=2 for a worksheet with the default size of rows=100, cols=26 -- caused step 1 to return a 400 response.

I am working on a pull request that addresses this case, by calling worksheet.resize() separately for columnCount and then again for rowCount. I'll add you as a reviewer when it's done.

from gspread-dataframe.

robin900 avatar robin900 commented on May 23, 2024 1

@devironl Sorry, can't add you as a reviewer to PR, but there is full test coverage on the new code and I'll be making a new PyPI release in about 30 min.

from gspread-dataframe.

robin900 avatar robin900 commented on May 23, 2024 1

@devironl Release 3.2.1 is now in PyPI.

from gspread-dataframe.

devironl avatar devironl commented on May 23, 2024

I was finally able to fix this by pre-defining the number of rows and colons of the sheets before setting the dataframe

output_sheet = client.open("sheet_name").add_worksheet(sheet_name, df.shape[0], df.shape[1])
set_with_dataframe(output_sheet, df, resize=True)

I hope this post will help someone else !

from gspread-dataframe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.