3
3
from tkinter .ttk import *
4
4
from tkcalendar import *
5
5
from ttkwidgets .autocomplete import *
6
+ import pandas as pd
6
7
import re
7
8
import csv
8
9
@@ -70,7 +71,27 @@ def __init__(self, master):
70
71
self .master = master
71
72
72
73
### Variables for controlled parameters ###
73
-
74
+
75
+ df = pd .read_csv ("Data.csv" )
76
+
77
+ self .OR = list (df .OR [df .OR .notna ()].values )
78
+ self .promotor = list (df .Promoter [df .Promoter .notna ()].values )
79
+ self .KIKO = list (df .Driver [df .Driver .notna ()].values )
80
+ self .replaced = list (df .Transgene [df .Transgene .notna ()].values )
81
+ self .reporter = list (df .Reporter [df .Reporter .notna ()].values )
82
+
83
+ # for row in csv_reader:
84
+ # for i in range(len(row)):
85
+ # if (i == 0) & (row[i] !=pd.NA): #ORs
86
+ # self.OR.append(row[i])
87
+ # elif (i == 1) & (row[i] != pd.NA): #Promoter
88
+ # self.promotor.append(row[i])
89
+ # elif (i == 2) & (row[i] != pd.NA): #Driver
90
+ # self.replaced.append(row[i])
91
+ # elif (i == 3) & (row[i] != pd.NA): #Transgene
92
+ # self.KIKO.append(row[i])
93
+ # elif (i == 4) & (row[i] != pd.NA): #Reporter
94
+ # self.reporter.append(row[i])
74
95
75
96
76
97
@@ -80,12 +101,6 @@ def __init__(self, master):
80
101
81
102
self .userDict = {"Nicolas" : 1 , "Yann" : 2 ,
82
103
"Ilham" : 3 , "Ivan" : 4 , "Dan" : 5 ,"Axel" : 6 }
83
- self .Driver = ["OR42b" , "OR47b" , "OR59b" , "OR22ab" , "ORCO" ]
84
- self .promotor = ["OR42b" , "OR47b" , "OR59b" , "OR22ab" , "ORCO" ]
85
- self .replaced = ["Gal4" ,"Boosted Gal4" ]
86
- self .KIKO = ["Knockin" , "Transgene" , "other" ]
87
- self .OR = ["Endogenous" ,"Empty" ] + ["DmOR%d" % id for id in range (1 , 30 )]
88
- self .reporter = ["GCaMP7f" ]
89
104
self .T2A = ["F" , "TB" , "TA" ]
90
105
self .sex = ["M" , "F" ]
91
106
self .Age = list (range (1 , 10 ))
@@ -536,6 +551,22 @@ def createNewElement(self, Newmaster,category):
536
551
globals ()[f"{ i } " ]["values" ] = newlist
537
552
# set the current selection to the new OR created
538
553
globals ()[f"{ i } " ].current ((len (globals ()[f"{ i } " ]["values" ])- 1 ))
554
+
555
+ df = pd .read_csv ("Data.csv" )
556
+ NAs = list (df .loc [pd .isna (df [category ]),:].index )
557
+ if len (NAs ) == 0 :
558
+ print (df .columns .get_loc (category ))
559
+ col_index = df .columns .get_loc (category )
560
+ to_append_df = [pd .NA ]* len (df .columns )
561
+ to_append_df [col_index ] = value
562
+ print (to_append_df )
563
+ df = df .append (pd .Series (to_append_df , index = df .columns ), ignore_index = True )
564
+ print (df .head )
565
+ else :
566
+ index = NAs [0 ]
567
+ df .loc [index ,category ] = value
568
+
569
+ df .to_csv ("Data.csv" ,index = False )
539
570
540
571
Newmaster .destroy () # quit the new window
541
572
else :
0 commit comments