def get_args_from_content(content): from tssplit import tssplit #splited = content.split(" ") splited = tssplit(content, quote='"', delimiter=' ') if len(splited) == 2: return splited[1] return splited[1:]
def parse(cls, terms: str): parsed_terms = tssplit( terms, quote='"', delimiter=' ') must = [] optional = [] for term in parsed_terms: if term.endswith('!'): must.append(term[:-1]) else: optional.append(term) return must, optional
def generic_updater(message, field): settings_key = get_settings_path(message) s3_client = get_s3_client() settings = info_from_s3(settings_key, s3_client) if not settings: return no_config_file() from tssplit import tssplit new_value = tssplit(message.content, quote='"', delimiter=' ')[1] #new_value = message.content.split(" ")[1] settings[field] = new_value upload_to_s3(settings, settings_key, s3_client) return get_translation(settings[LANGUAGE], 'configuration.successfull_update')
import sqlite3, csv from tssplit import tssplit conn = sqlite3.connect("nba.sqlite") cur = conn.cursor() with open('nba.csv', 'r') as file: no_record = 0 for row in file: cur.execute("INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?,?)", tssplit(row, quote='"', delimiter=',')) conn.commit() no_record += 1 conn.close() print('\n{} Records Transferred'.format(no_record))
def string_to_array(s, delimiter=",", quote='"', strip=True, escape="^"): return [ token.strip() if strip else token for token in tssplit( s, quote=quote, delimiter=delimiter, escape=escape) ]