-
Notifications
You must be signed in to change notification settings - Fork 0
/
correction.py
66 lines (57 loc) · 1.78 KB
/
correction.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
from __future__ import print_function # Python 2/3 compatibility
import boto3
import json
import decimal
from boto3.dynamodb.conditions import Key, Attr
import os
os.environ["NO_PROXY"] = "s3.amazonaws.com"
dynamodb=boto3.resource('dynamodb')
table=dynamodb.Table('hungrymind-mobilehub-593518188-BookBorrow')
import csv
'''csv_columns = ['DateOfBorrow','SupplierID','BookID','DateClaimToRet','BorrowID','CustID','ActualRetDate','CustId','BookId']
table=dynamodb.Table('hungrymind-mobilehub-593518188-Borrowed')
#response=table.scan()
dict_data = response['Items']
csv_file = "mydataaa.csv"
try:
with open(csv_file, 'w') as csvfile:
writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
writer.writeheader()
for data in dict_data:
writer.writerow(data)
except IOError:
print("I/O error")
'''
with open('mydataaa.csv','rt')as f:
data = csv.reader(f)
print(data)
for i in data:
#i=data[i]
print(i)
if(len(i)>0 and i[7]=="" and i[1]=='1'):
import random
r=random.uniform(0, 5)
s=""
for j in i[2]:
if (j=='E'):
break;
elif(not j=='.'):
s+=j
s2=""
for j in i[5]:
if(j=='.'):
break
else:
s2+=j
table.put_item(
Item={
'BorrowId':int(i[4]),
'ActualRetDate':i[6],
'BookID':int(s),
'CustID':int(s2),
'DateClaimToRet':i[3],
'DateOfBorrow':i[0],
'SupplierID':'1',
'Rating' : str(r)
}
)