-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPythonEn.py
85 lines (85 loc) · 2.47 KB
/
PythonEn.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import sys
import os
import csv
#
#
def Climate(str,str1,str2):
str = (int(str))<<14
str1 = (int(str1))<<7
str2 = int(str2)
res = str|str1|str2
return res
#
def DateAndTime(str):
minus = None
if "+" in str:
minus = False
pass
else:
minus = True
pass
str = str.replace("-"," ")
str = str.replace(":"," ")
str = str.replace("."," ")
str = str.replace("T"," ")
str = str.replace("+"," ")
rAw = str.split(" ")
rAw[0] = (int(rAw[0]))<<47
rAw[1] = (int(rAw[1]))<<43
rAw[2] = (int(rAw[2]))<<38
rAw[3] = (int(rAw[3]))<<33
rAw[4] = (int(rAw[4]))<<27
rAw[5] = (int(rAw[5]))<<21
rAw[6] = (int(rAw[6]))<<11
rAw[7] = (int(rAw[7]))<<6
rAw[8] = (int(rAw[8]))
res = rAw[0]|rAw[1]|rAw[2]|rAw[3]|rAw[4]|rAw[5]|rAw[6]|rAw[7]|rAw[8]
if minus:
res = res * -1
pass
return res
#
def EXE(str):
if os.path.exists(str):
print("ARCHIVO ENCONTRADO!")
with open(str) as csv_file:
print("Leyendo archivo...")
csv_reader = csv.reader(csv_file, delimiter=',')
line_count = 0
#
salida = 'output.csv'
head = ['DateAndTime','Climate']
#
header = None
if os.path.exists(salida):
header = False
pass
else:
header = True
pass
#
for row in csv_reader:
if line_count == 0:
print('Transformando informacion...')
line_count += 1
pass
else:
rows = [DateAndTime(row[0]),Climate(row[1],row[2],row[3])]
with open(salida,"a+",newline='') as csv_file:
csvwriter = csv.writer(csv_file)
if header:
csvwriter.writerow(head)
header = False
pass
csvwriter.writerow(rows)
pass
pass
pass
#
pass
pass
#
#
print("CODIFICADOR DEL CLIMA")
print("Buscando archivo...")
EXE("input.csv")