排除Google表格中没有任何数据的行

时间:2018-05-07 13:52:21

标签: google-apps-script google-sheets

我已调整此脚本以验证M列中的所有单元格以获取特定数据:

var range_input = sheet.getRange("M2:M").getValues();
var filtered_input = range_input.filter(String);

虽然它有效,但它还将验证添加到空白行,如下所示:

enter image description here

我试图使用这样的东西来忽略空白行:

sheet.getRange("QUERY(test!A:N,"SELECT * where A is not null")").setDataValidation(dv);

..然后将其反馈到数据验证中,但我认为我的思维过程在这里是不正确的,因为过滤器将从这些列中提取数据,而我只需要从getRange查询中排除实际的空行

我也试过使用它(基本上删除了所有空白行),但似乎查询命令不能在脚本中使用,否则它可能会起作用。

import os

import logging
import sys
logging.basicConfig(stream=sys.stdout,level=logging.DEBUG)
log = logging.getLogger('my_application')


from proj.heroku_env_vars import teleg_token,secret_key



import telegram
from flask import Flask, request

app = Flask(__name__)
app.debug = True

global bot
bot = telegram.Bot(token=TOKEN)


@app.route('/%s'%HOOK, methods=['POST'])
def webhook_handler():
    if request.method == "POST":
        log.info('post from teleg')
        # retrieve the message in JSON and then transform it to Telegram object
        update = telegram.Update.de_json(request.get_json(force=True))

        chat_id = update.message.chat.id

        # Telegram understands UTF-8, so encode text for unicode compatibility
        text = update.message.text.encode('utf-8')

        # repeat the same message back (echo)
        bot.sendMessage(chat_id=chat_id, text=text)
    else:
        log.info('notpost from teleg')

    return 'ok'


@app.route('/swh', methods=['GET', 'POST'])
def set_webhook():
    s = bot.setWebhook('%s/%s'%(URL, HOOK), PORT=8443)
    if s:
        return "webhook setup ok"
    else:
        return "webhook setup failed"


@app.route('/dwh', methods=['GET', 'POST'])
def delete_webhook():
    s = bot.deleteWebhook()
    if s:
        return "webhook deleted ok"
    else:
        return "webhook delete failed"


@app.route('/')
def index():
    log.info('i made this request')
    return 'home page.'

会感激一些帮助。

0 个答案:

没有答案