Skip to content

Commit 7f3a2eb

Browse files
committed
de-duplicate column names when .csv import
especially as the error message is hidden
1 parent ba769fe commit 7f3a2eb

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ Changelog
22
=========
33

44

5+
2019-05-02a : v0.9.0 'De-duplicate column names!'
6+
-------------------------------------------------
7+
8+
* header columns in a .csv file are de-duplicated to avoid error: 'a', 'a', 'a_1' becomes 'a', 'a_2', 'a_1'
9+
510
2016-03-06a : v0.8.11 'Combine Functions!'
611
------------------------------------------
712

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def read(*paths):
5050
'Programming Language :: Python :: 3.3',
5151
'Programming Language :: Python :: 3.4',
5252
'Programming Language :: Python :: 3.5',
53+
'Programming Language :: Python :: 3.6',
54+
'Programming Language :: Python :: 3.7',
55+
'Programming Language :: Python :: 3.8',
5356
'Topic :: Scientific/Engineering :: Information Analysis',
5457
]
5558
)

sqlite_bro/sqlite_bro.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class App:
3131
"""the GUI graphic application"""
3232
def __init__(self):
3333
"""create a tkk graphic interface with a main window tk_win"""
34-
self.__version__ = '0.8.11'
35-
self._title = "2016-03-06a : 'Combine Functions!'"
34+
self.__version__ = '0.9.0'
35+
self._title = "2019-04-02a : 'De-duplicate column names!'"
3636
self.conn = None # Baresql database object
3737
self.database_file = ""
3838
self.tk_win = Tk()
@@ -1076,6 +1076,13 @@ def guess_sql_creation(table_name, separ, decim, header, data, quoter='"'):
10761076
pass
10771077
checker.close
10781078
if header:
1079+
# de-duplicate column names, if needed by pastixing with '_'+number
1080+
for i in range(len(r)):
1081+
if r[i] in r[:i] :
1082+
j=1
1083+
while r[i]+'_'+str(j) in r[:i] + r[i+1:]:
1084+
j +=1
1085+
r[i]+= '_'+str(j)
10791086
head = ",\n".join([('"%s" %s' % (r[i], typ[i]))
10801087
for i in range(len(r))])
10811088
sql_crea = ('CREATE TABLE "%s" (%s);' % (table_name, head))

0 commit comments

Comments
 (0)