# 1. Original JSON String
text = """{ "count": 2, "record": [ {"lemma":"God"}, {"lemma":"Men"} ] }"""
# 2. Text to JSON object
import json
j = json.loads(text)
# 3. Parse a top-level property
print 'count: ' + str( j['count'] )
# 4. Traverse multiple records
for item in j['record']:
print( item['lemma'] )
2015-07-13
PYTHON - Break a paragraph into a sentences list
import re
text = 'This is. A paragraph with. Three sentences.'
sentences = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s', text)
for item in sentences:
print(item)
text = 'This is. A paragraph with. Three sentences.'
sentences = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s', text)
for item in sentences:
print(item)
PYTHON - Getting text from a website
import requests
txt = requests.get("http://lipsum.com/robots.txt").text
print( txt )
txt = requests.get("http://lipsum.com/robots.txt").text
print( txt )
2015-07-11
MySQL - Convert table's charset and collation to utf8/utf8_general_ci (for English, Spanish and French characters)
ALTER TABLE table_name_here CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
MySQL - Charset and collation that works for English, Spanish and French characters
CHARACTER SET: utf8
COLLATION: utf8_general_ci
COLLATION: utf8_general_ci
2015-07-09
EXCEL - Figure out if a cell contains a number (any digit)
=COUNT( FIND( {0,1,2,3,4,5,6,7,8,9}, A2 ) ) > 0
2015-07-08
PYTHON - Display and change current working directory
import os
print( os.getcwd() )
os.chdir( os.path.dirname("C:/folder/subfolder") )
print( os.getcwd() )
print( os.getcwd() )
os.chdir( os.path.dirname("C:/folder/subfolder") )
print( os.getcwd() )
Subscribe to:
Posts (Atom)