From c44d1abd1b10a92c49b84077799dcae31f7c8aa6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Frans=20Pondaco=20Winandy?=
 <jvfpw18@inf.ufpr.br>
Date: Thu, 18 Jul 2019 08:30:27 -0300
Subject: [PATCH] Fix insertion when two columns are based in the same header

---
 database/protocol.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/database/protocol.py b/database/protocol.py
index 2316a7f..10886a7 100644
--- a/database/protocol.py
+++ b/database/protocol.py
@@ -74,9 +74,19 @@ class Protocol(object):
         if not indexes:
             return None
         if len(indexes) > 1:
-            return None
+            self.resolve_duplicates(year, indexes)
+
         return self._remaped[indexes[0]]
 
+    def resolve_duplicates(self, year, indexes):
+        '''
+        Transforms a dbcolumn that gets the data from the same header to a denormalization of the first column.
+        '''
+        original_dbcolumn = self.dbcolumn_from_target(self._remaped[indexes[0]])[0]
+
+        for i in range(1, len(indexes)):
+            self._dataframe.loc[indexes[i], year] = '~' + original_dbcolumn
+
     def original_from_target(self, name, year):
         '''Gets original column from target column and a year
         Input example: **{'name': 'CEBMA015N0', 'year': '2015'}
-- 
GitLab