-
Notifications
You must be signed in to change notification settings - Fork 1
/
Write_data.py
46 lines (39 loc) · 1.51 KB
/
Write_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import csv
from itertools import zip_longest
import pandas as pd
with open ("Data.csv","w", encoding='UTF8', newline='') as f:
writer = csv.writer(f,delimiter=",")
writer.writerow(["OR","Promoter","Driver","Transgene","Reporter"])
OR = ["Endogenous","Empty"] + ["DmOR%d" % id for id in range(1, 30)]
promotor = ["OR42b", "OR47b", "OR59b", "OR22ab", "ORCO"]
replaced = ["Gal4","Boosted Gal4"]
KIKO = ["Knockin", "Transgene", "other"]
reporter = ["GCaMP7f"]
d = [OR,promotor,replaced,KIKO,reporter]
rows = zip_longest(*d, fillvalue = pd.NA)
writer.writerows(rows)
def load_csv(filename):
odour = dict()
# Open file in read mode
file = open(filename,"r")
# Reading file
csv_reader = csv.reader(file)
OR = []
Promoter = []
Driver = []
Transgene = []
Reporter = []
for row in csv_reader:
for i in range(len(row)):
if (i == 0) & (row[i] != ''): #ORs
OR.append(row[i])
elif (i == 1) & (row[i] != ''): #Promoter
Promoter.append(row[i])
elif (i == 2) & (row[i] != ''): #Driver
Driver.append(row[i])
elif (i == 3) & (row[i] != ''): #Transgene
Transgene.append(row[i])
elif (i == 4) & (row[i] != ''): #Reporter
Reporter.append(row[i])
return (OR,Promoter,Driver,Transgene,Reporter)
print(load_csv("Data.csv"))