This repository was archived by the owner on Sep 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputBids.py
More file actions
50 lines (44 loc) · 1.45 KB
/
Copy pathinputBids.py
File metadata and controls
50 lines (44 loc) · 1.45 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
def deleteDummy(goodsNumber, bids):
for a in range(0, len(bids)):
bids[a] = [x for x in bids[a] if x < goodsNumber]
return bids
def getAuction(path):
file = open(path, 'r')
text2 = file.readlines()
text = []
for x in text2:
if (x[0] != '\n' and x[0] != '%'):
text.append(x)
goodsNumber = 0
bidsNumber = 0
dummyNumber = 0
bidsValue = []
bids = []
for x in text: # for eachline in text
if 'good' in x:
goodsNumber = int(x[5:])
else:
if 'bids' in x:
bidsNumber = int(x[4:])
else:
if 'dummy' in x:
dummyNumber = int(x[5:])
else:
new = x.split()
index = 0
value = 0
listBid = []
for x in range(0, len(new)):
if x == 0:
index = new[x]
else:
if x == 1:
value = new[x]
else:
if new[x] != '#':
listBid.append(int(new[x]))
bidsValue.append(float(value))
bids.append(listBid)
bids = deleteDummy(goodsNumber, bids)
returnValue = [goodsNumber, bidsNumber, dummyNumber, bidsValue, bids]
return (returnValue)