Skip to content

Instantly share code, notes, and snippets.

View AvinashDalvi89's full-sized avatar
🏠
Working from home

Avinash Dalvi AvinashDalvi89

🏠
Working from home
View GitHub Profile
select * from
(select callTime,callType,employee,phoneNumber,count(*) as n from table2 group by callTime,callType,employee,phoneNumber) x
where x.n > 1;
delete a
from leads a
LEFT JOIN
(
SELECT MIN(ID) ID,phone
@AvinashDalvi89
AvinashDalvi89 / nested-json-tree-based.py
Created February 5, 2020 13:21
This is to convert list of dictionary which will have child- parent relation to each other. This will convert to nested hierarchy
data = [
{ "name" : "ABC", "parent":"DEF", },
{ "name" : "DEF", "parent":"null" },
{ "name" : "new_name", "parent":"ABC" },
{ "name" : "new_name2", "parent":"ABC" },
{ "name" : "Foo", "parent":"DEF"},
{ "name" : "Bar", "parent":"null"},
{ "name" : "Chandani", "parent":"new_name", "relation": "rel", "depth": 3 },
{ "name" : "Chandani333", "parent":"new_name", "relation": "rel", "depth": 3 }
]
@AvinashDalvi89
AvinashDalvi89 / non-ascii-removal.py
Created January 16, 2020 09:52
This to remove non ASCII characters from string
import re
ini_string = "'technews One lone dude awaits iPad 2 at Apple\x89Ûªs SXSW store"
res1 = " ".join(re.split("[^A-Za-z0-9]+", ini_string))
print(res1)
if re.match("[^\t\r\n\x20-\x7E]+", ini_string):
print("found")
result = ini_string.encode().decode('ascii', 'replace').replace(u'\ufffd', '`')
result2 = ini_string.encode().decode("utf-8").replace(u"\x89Ûª", "`").encode("utf-8")