Sunday, February 23, 2020

How to use regex in PHP Mongo query

use MongoRegex class.

$query = array(    'English' => new MongoRegex('/'.$search_word.'/i'));
//var_dump($query);

$result = $collection->find($query)->limit(100);

using python gspread to read google sheets

https://github.com/burnash/gspread

#!/usr/bin/python# -*- coding: utf-8 -*-import gspread
from oauth2client.service_account import ServiceAccountCredentials
# use creds to create a client to interact with the Google Drive APIscope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('key.json', scope)
client = gspread.authorize(creds)
gss = client.open_by_url("url of sheet")

#list_of_hashes = sheet.get_all_records()#print(len(list_of_hashes))#print(list_of_hashes)