E
E
Emil Revencu2018-07-22 08:45:39
Python
Emil Revencu, 2018-07-22 08:45:39

How to add a Google Sheet column to a specific location (Python, gspread)?

How to add a Google Sheet column to a specific location (Python, gspread)?
There is a function add_cols(cols)but it adds a column to the end, but you need to insert it in a certain place

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ivanov, 2019-01-28
@oshliaer

Use the core API

sht = gc.open_by_key(spreadsheetId)

requests = []

requests.append({
      "insertDimension": {
        "range": {
          "sheetId": sheetId,
          "dimension": "COLUMNS",
          "startIndex": 2,
          "endIndex": 4
        },
        "inheritFromBefore": True
      }
    })

body = {
    'requests': requests
}

sht.batch_update(body)

You can run the code "here and now" at the link https://colab.research.google.com/drive/1IWmX5xuOE...
  • https://developers.google.com/sheets/api/samples/r...
  • https://gspread.readthedocs.io/en/latest/api.html?...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question