commit 0d5be3e838b730dc72c4e250203d4054dcb75267 Author: Chen, Chien-ting Date: Wed Mar 9 23:24:44 2016 +0800 init commit diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..d1eb7c8 --- /dev/null +++ b/__main__.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +#-*-coding:utf-8-*- +import sqlite3 + +def table2list(table_tsv): + with open(table_tsv,'r',encoding='utf-16') as tsv: + code_list = [] + for line in tsv: + line_stripped = line.strip() + code_char_mapping = tuple(line_stripped.split()) + + code_list.append(code_char_mapping) + return code_list + + +def list2sqlite(code_list): + + db = sqlite3.connect('table_db.sqlite') + c = db.cursor() + + c.execute('''CREATE TABLE ime + (code text, char text)''') + c.executemany( + 'INSERT INTO ime VALUES (?,?)', code_list) + db.commit() + db.close() + +def import_all_table(): + import os + import re + table_folder = os.path.join('.','table') + for file in os.listdir(table_folder): + if re.match('.+\.txt$',file): + file_path = os.path.join(table_folder,file) + list = table2list(file_path) + list2sqlite(list) + + + + +import_all_table() + + + + diff --git a/table/array30_27489-V201509.txt b/table/array30_27489-V201509.txt new file mode 100644 index 0000000..38cfccb Binary files /dev/null and b/table/array30_27489-V201509.txt differ diff --git a/table/array30_ExtB_V2016A.txt b/table/array30_ExtB_V2016A.txt new file mode 100644 index 0000000..6dfbed9 Binary files /dev/null and b/table/array30_ExtB_V2016A.txt differ diff --git a/table_db.sqlite b/table_db.sqlite new file mode 100644 index 0000000..492cdf2 Binary files /dev/null and b/table_db.sqlite differ