Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow us to set how uploaded data should be interpreted. #44

Open
Ctilhs opened this issue Feb 5, 2019 · 8 comments
Open

Allow us to set how uploaded data should be interpreted. #44

Ctilhs opened this issue Feb 5, 2019 · 8 comments

Comments

@Ctilhs
Copy link

Ctilhs commented Feb 5, 2019

From what I understand, by default when we use the upload() from df2gspread, dataframe values are converted to string then upload is performed.

I struggled with it when I had to upload values which were prices. Same situation if I would like them to stay as digits after update, without my interaction in google docs.

Simple fix.
In upload() add argument value_input_opt='RAW'

def upload(df, gfile="/New Spreadsheet", wks_name=None,
col_names=True, row_names=True, clean=True, credentials=None,
start_cell = 'A1', df_size = False, new_sheet_dimensions = (1000,100)):

And in three function calls value_input_option=value_input_opt

wks.update_cells(cell_list)

wks.update_cells(cell_list)

wks.update_cells(cell_list)

From: developers.google.com
What we get? Now in upload we could set parameter value_input_option='USER_ENTERED', so when we upload digits they will be automatically parsed as numbers.
If we will not specify value_input_option in upload() it will stay default as 'RAW' so data will be uploaded as it is now.

Not sure is it related?: #41

It's my first time ever adding Issue at github. I will gladly accept advice if I should improve something.

@saitx
Copy link

saitx commented Feb 21, 2019

Yeah for now I have been having a duplicate sheet with =VALUE(Raw_Sheet!H2) and so on. This would be a great addition. Something like a dtype parameters that pandas has would be great.

@maybelinot
Copy link
Owner

@Ctilhs thank you for creating an issue, that would be great if you could submit a PR with proposed changes. Otherwise I'll work on this as soon as I'll have time.

@winf-hsos
Copy link

Any updates on this?

@varunjain3
Copy link

Are the authors alive? I wanted this as well, shall I create a pr?

@maybelinot
Copy link
Owner

Hi @varunjain3 I don't actively support the lib anymore, if you will open a pr with tests - I'll review and bump the lib version

@varunjain3
Copy link

Thanks for the prompt reply, I’ll do the needful, also are there any alternatives you found for the same project?

@maybelinot
Copy link
Owner

Not really, df2gspread mainly leverages https://github.com/burnash/gspread, which is update regularly from what I can see, so you may built small abstraction layer to fulfil your needs just on top of that.

@mroy-seedbox
Copy link

I'd suggest abandoning (that's what we did), when an entire library can be replaced with a couple lines of monkey patching in the actively maintained gspread lib:

    def upload_pandas_df(self, df):
      values = [df.columns.values.tolist()]
      values.extend(df.values.tolist())
      sheet.values_update(
        self.title,
        params = { 'valueInputOption': 'USER_ENTERED' },
        body = { 'values': values }
      )

    gspread.Worksheet.upload_pandas_df = upload_pandas_df

Or use gspread-dataframe instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants