# Download the dataset. It's small, only about 6 MB.
if not os.path.exists('./ml-1m'):
url = 'http://files.grouplens.org/datasets/movielens/ml-1m.zip'
response = requests.get(url, stream=True)
total_length = response.headers.get('content-length')
bar = tqdm.tqdm_notebook(total=int(total_length))
with open('./ml-1m.zip', 'wb') as f:
for data in response.iter_content(chunk_size=4096):
f.write(data)
bar.update(4096)
zip_ref = zipfile.ZipFile('./ml-1m.zip', 'r')
zip_ref.extractall('.')
zip_ref.close()


def get_query(model_name):
return {
'a': 'SELECT * FROM TB_MODEL WHERE MODEL=\'a\'',
'b': 'SELECT * FROM TB_MODEL WHERE MODEL=\'b\'',
'c': 'SELECT * FROM TB_MODEL WHERE MODEL=\'c\'',
'd': 'SELECT * FROM TB_MODEL WHERE MODEL=\'d\'',
'e': 'SELECT * FROM TB_MODEL WHERE MODEL=\'e\'',
'f': 'SELECT * FROM TB_MODEL WHERE MODEL=\'f\'',
'g': 'SELECT * FROM TB_MODEL WHERE MODEL=\'g\''
}[model_name]


strings = ["first", "", "second ", " "]
strings = [x.strip() for x in strings if x.strip()]

결과 : ["first", "second"] 

+ Recent posts