-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteste2.py
More file actions
138 lines (104 loc) · 2.55 KB
/
teste2.py
File metadata and controls
138 lines (104 loc) · 2.55 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import math
import csv
'''
def executeIteration(unidade, Valor):
if unidade == 'Dollars (millions)':
Valor = float(Valor.replace(',', '.'))
return Valor
'''
'''
with open('D:\\OneDrive\\Documentos\\GlobalSystem\\FICO\\JobsDMPS\\annual-enterprise-survey-2019-financial-year-provisional-csv.csv', 'r') as arquivo_csv:
leitor = csv.reader(arquivo_csv, delimiter=',')
count = 0
for coluna in leitor:
count+=1
if count <= 1:
print(coluna)
'''
'''
fields = {'Valor': '736,750'}
# print('%.2f' % (executeIteration(unidade, valor)))
def trataValor(fields):
if fields['Unidade'] == 'Dollars (millions)' and isinstance(fields['Valor'], str):
fields['Valor'] = float(fields['Valor'].replace(',','.'))
return fields
def trataValor2(fields):
if isinstance(fields['Valor'], str):
fields['Valor'] = float(fields['Valor'].replace(',',''))
return fields
# print(trataValor2(fields))
tuplas = '123,555', 123.555
count = 0
for tupla in tuplas:
if isinstance(tupla, str) and ',' in tupla:
aux = tupla.replace(',','')
tlist = list(tuplas)
tlist[cou]
print(tuplas)
linha = '6,1,3,5,2,4'
linha = linha.replace(',','')
arrayLinha = list(linha)
arrayLinha.sort()
print(arrayLinha)
'''
'''
import json
with open('sample.json', 'r') as json_file:
dados = dict(json.load(json_file))
dadosOrd = sorted(dados['transacoes'], key = lambda k: k['valor'])
print (dadosOrd)
'''
'''
def trataPrice(field):
if ',' in field['Price']:
field['Price'] = float(field['Price'].replace(',',''))
else:
field['Price'] = float(field['Price'])
return field
'''
'''
def initializeTuple():
val = 1
def executeIteration(number):
return float(group(number))
def group(number):
s = str(number)
if ',' in str(number):
index = str(number).find(',')
s = number[0:index]
return s + number[index+1:]
else:
return s
print(executeIteration(field))
'''
'''
def initializeTuple():
val = 1
def executeIteration(number):
return float(group(number))
def group(number):
s = str(number)
if ',' in s:
s = s.replace(',','')
return s
else:
return s
field = '133,000.45'
print(executeIteration(field))
'''
array = [0,1,2]
tam = len(array) - 1
json = {
'Num1': array[0],
'Num2': array[1],
'Num3': array[2],
'Num4': (array[3] if tam == 3 else ''),
'Num5': (array[4] if tam == 4 else ''),
}
json2 = {}
for key, val in json.items():
if tam >= 0:
json2[key] = val
tam -= 1
print(json)
print(json2)