-
Notifications
You must be signed in to change notification settings - Fork 0
/
Iterator.py
70 lines (64 loc) · 2.83 KB
/
Iterator.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
#coding:utf8
import json
import urllib2
from azure.storage import TableService, Entity
class Iterator:
def __init__(self,table):
self.DataCollector = []
self.i=0
self.Table=table
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
self.task = self.table_service.query_entities(self.Table, None, None, 100)
if table=="Customer":
self.i=self.i+100
print(self.i)
for line in self.task:
self.DataCollector.append({'ID': line.RowKey,
'Name' : line.Name ,
'Country' : line.Country,
'City' : line.City})
self.iteratorCustomer(self.task)
if table=="Order":
self.i=self.i+100
print(self.i)
for line in self.task:
self.DataCollector.append({'ID': line.RowKey,
'CustomerID' : line.CustomerID,
'ProductID' : line.ProductID,
'Datetime' : line.Datetime,
'TotalPrice' : line.TotalPrice})
self.iteratorOrder(self.task)
def iteratorCustomer(self,task):
try:
data = self.table_service.query_entities(self.Table, None, None, 100,
task.x_ms_continuation['NextPartitionKey'],
task.x_ms_continuation['NextRowKey'])
self.i=self.i+len(data)
print(self.i)
for line in data:
self.DataCollector.append({'ID': line.RowKey,
'Name' : line.Name ,
'Country' : line.Country,
'City' : line.City})
self.iteratorCustomer(data)
except:
pass
def iteratorOrder(self,task):
try:
data = self.table_service.query_entities(self.Table, None, None, 100,
task.x_ms_continuation['NextPartitionKey'],
task.x_ms_continuation['NextRowKey'])
self.i=self.i+len(data)
print(self.i)
for line in data:
self.DataCollector.append({'ID': line.RowKey,
'CustomerID' : line.CustomerID,
'ProductID' : line.ProductID,
'Datetime' : line.Datetime,
'TotalPrice' : line.TotalPrice})
self.iteratorOrder(data)
except:
pass
def getDatas(self):
return self.DataCollector