From 577807023264bf4364ad413211c1f156c4cfeea1 Mon Sep 17 00:00:00 2001 From: stonebig Date: Fri, 4 Feb 2022 08:20:28 +0100 Subject: [PATCH] Ensure a column name for no-name columns --- HISTORY.rst | 6 ++++++ sqlite_bro/sqlite_bro.py | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c1b841d..c0cafab 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,12 @@ Changelog ========= +2022-02-04a : v0.12.2 'Filling the blanks !' +-------------------------------------------- + +* empty columns names are always replaced per the default 'c_nnn' convention + + 2021-08-15a : v0.12.1 'Pop-up results to excel !' ------------------------------------------------- diff --git a/sqlite_bro/sqlite_bro.py b/sqlite_bro/sqlite_bro.py index 5b00af8..4823265 100644 --- a/sqlite_bro/sqlite_bro.py +++ b/sqlite_bro/sqlite_bro.py @@ -40,8 +40,8 @@ class App: def __init__(self, use_gui=True): """create a tkk graphic interface with a main window tk_win""" - self.__version__ = "0.12.1" - self._title = "of 2021-08-15a : 'Pop-up results to .excel !'" + self.__version__ = "0.12.2" + self._title = "of 2022-02-04a : 'Filling the blanks !'" self.conn = None # Baresql database object self.database_file = "" self.initialdir = "." @@ -1619,7 +1619,10 @@ def guess_sql_creation(table_name, separ, decim, header, data, quoter='"'): if header: # de-duplicate column names, if needed by pastixing with '_'+number for i in range(len(r)): - if r[i] in r[:i]: + + if r[i] == "": # 2022-02-04a replace empty column title per usual default + + r[i] = "c_" + ("000" + str(i))[-3:] if r[i] in r[:i]: j = 1 while r[i] + "_" + str(j) in r[:i] + r[i + 1 :]: j += 1