Python Forum
Blockspring Trello export to Google Sheet
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Blockspring Trello export to Google Sheet
#1
I have a Trello board synced with a google sheet. I want to start adding my own code. Specifically i would like to export each checklist item to its own Cell. Is this possible?

import google_sheets_app
import trello_app

## STEP 1: SIGN IN WITH GOOGLE SHEETS IN THE SIDEBAR
## STEP 2: PASTE A GOOGLE SHEET'S ID BELOW (FOUND IN ITS URL)
sheet_id = "1NyDlqBmgeTS2Zs8fzjihTulrd5xaJ_FkWNTib_8hVLw"


def export_to_sheets():
    # get all open cards in this board
    board = trello_app.get_current_board()
    cards = board.get_cards(filter="open")

    # export cards to the google sheet
    sheet = google_sheets_app.get_spreadsheet_by_id(sheet_id).get_sheets()[0]
    sheet.write_values(cards)


def import_from_sheets():
    # read the google sheet
    sheet = google_sheets_app.get_spreadsheet_by_id(sheet_id).get_sheets()[0]
    sheet_data = sheet.get_values()

    # for each row in sheet
    for row in sheet_data:
        # look for an ID column, and lookup that card
        card = trello_app.get_card_by_id(row.get("id"))

        # if you find a card, update it with the row
        if card:
            card.set_field(row)
        # if this card doesn't exist, create it
        else:
            li = trello_app.get_list_by_id(row.get("idList"))
            li.create_card(row)

    # when done, pull updated card list into sheets
    export_to_sheets()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 2,676 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  Iterate through google sheet alcz 0 3,734 Aug-04-2020, 06:58 AM
Last Post: alcz
  how to import files in Google Collab wihout downloading them to PC and to Google Disk sveto4ka 9 3,873 Jun-03-2020, 12:40 PM
Last Post: sveto4ka
  Excel: Apply formating of a sheet(file1) to another sheet(file2) lowermoon 1 2,038 May-26-2020, 07:57 AM
Last Post: buran
  Code Wireless Temperature sensor and send sensor readings to google sheet jenkins43 0 2,192 Nov-29-2018, 12:44 PM
Last Post: jenkins43
  inserting photos in 1 sheet of a 6 sheet excel file fails Pedroski55 0 2,375 Mar-03-2018, 01:53 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020