parent
02449fd472
commit
54f30cb527
@ -0,0 +1,95 @@ |
||||
// |
||||
// ChipCountParser.swift |
||||
// TournamentStats |
||||
// |
||||
// Created by Laurent Morvillier on 27/06/2019. |
||||
// Copyright © 2019 Stax River. All rights reserved. |
||||
// |
||||
|
||||
import Foundation |
||||
import RealmSwift |
||||
import Realm |
||||
|
||||
enum ChipCountColumns : CaseIterable { |
||||
case rank |
||||
case player |
||||
case chipcount |
||||
case trend |
||||
case city |
||||
case state |
||||
} |
||||
|
||||
class ChipCountParser { |
||||
|
||||
static func start() -> ChipCountManager { |
||||
|
||||
let realm = try! Realm() |
||||
|
||||
var ccm = ChipCountManager(chipCounts: [], totalChips: 0.0) |
||||
|
||||
try! realm.write { |
||||
|
||||
let resourceName = "chipcount" |
||||
let path: String? = Bundle.main.path(forResource: resourceName, ofType: "") |
||||
if let path = path { |
||||
do { |
||||
let data = try String(contentsOfFile: path, encoding: .utf8) |
||||
ccm = ChipCountParser.parse(realm: realm, data: data) |
||||
} catch { |
||||
print(error) |
||||
} |
||||
} else { |
||||
print("could not find path for chipcount") |
||||
} |
||||
|
||||
|
||||
} |
||||
return ccm |
||||
} |
||||
|
||||
static func parse(realm: Realm, data: String) -> ChipCountManager { |
||||
|
||||
// cleanup raw data |
||||
let rawRows = data.split(separator: "\n") |
||||
var rows = rawRows.map { String($0) } |
||||
rows = rows.filter { !$0.isEmpty } |
||||
|
||||
let columns = ChipCountColumns.allCases |
||||
let numberOfColumns = columns.count |
||||
|
||||
let formatter = Formatter.importData |
||||
|
||||
var playerName: String = "" |
||||
var totalChips: Double = 0.0 |
||||
var ccs: [ChipCount] = [] |
||||
|
||||
for i in 0..<rows.count { |
||||
let row: String = rows[i] |
||||
|
||||
let index = i % numberOfColumns |
||||
let currentColumn = columns[index] |
||||
|
||||
switch currentColumn { |
||||
case .rank: |
||||
break |
||||
case .player: |
||||
playerName = row |
||||
case .chipcount: |
||||
let chips = formatter.number(from: row)?.doubleValue ?? 0.0 |
||||
totalChips += chips |
||||
|
||||
let cc = ChipCount(player: playerName, chips: chips) |
||||
ccs.append(cc) |
||||
case .trend: |
||||
break |
||||
case .city: |
||||
break |
||||
case .state: |
||||
break |
||||
} |
||||
|
||||
} |
||||
return ChipCountManager(chipCounts: ccs, totalChips: totalChips) |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,79 @@ |
||||
1 |
||||
Phil Ivey |
||||
4,900,000 |
||||
+200,000 |
||||
- |
||||
- |
||||
2 |
||||
Josh Arieh |
||||
3,750,000 |
||||
+585,000 |
||||
- |
||||
- |
||||
3 |
||||
Bryce Yockey |
||||
2,485,000 |
||||
-265,000 |
||||
- |
||||
- |
||||
4 |
||||
David Oppenheim |
||||
2,400,000 |
||||
+200,000 |
||||
- |
||||
- |
||||
5 |
||||
Phillip Hui |
||||
1,880,000 |
||||
+245,000 |
||||
- |
||||
- |
||||
6 |
||||
Shaun Deeb |
||||
1,730,000 |
||||
+30,000 |
||||
- |
||||
- |
||||
7 |
||||
Dario Sammartino |
||||
1,400,000 |
||||
-87,000 |
||||
- |
||||
- |
||||
8 |
||||
John Esposito |
||||
1,207,000 |
||||
+157,000 |
||||
- |
||||
- |
||||
9 |
||||
Chris Vitch |
||||
1,100,000 |
||||
+120,000 |
||||
- |
||||
- |
||||
10 |
||||
Talal Shakerchi |
||||
660,000 |
||||
+140,000 |
||||
- |
||||
- |
||||
11 |
||||
Andrew Brown |
||||
510,000 |
||||
-110,000 |
||||
- |
||||
- |
||||
12 |
||||
Dan Cates |
||||
441,000 |
||||
+231,000 |
||||
- |
||||
- |
||||
13 |
||||
Chris Klodnicki |
||||
200,000 |
||||
-380,000 |
||||
- |
||||
- |
||||
|
||||
@ -1,217 +0,0 @@ |
||||
1 |
||||
United StatesBrian Green |
||||
$345,669 |
||||
1,084.8 |
||||
Decatur |
||||
TX |
||||
United States |
||||
2 |
||||
United StatesAli Imsirovic |
||||
$213,644 |
||||
542.4 |
||||
Vancouver |
||||
WA |
||||
United States |
||||
3 |
||||
United StatesAsher Conniff |
||||
$145,097 |
||||
488.2 |
||||
Brooklyn |
||||
NY |
||||
United States |
||||
4 |
||||
United StatesLoren Klein |
||||
$100,775 |
||||
433.9 |
||||
Verdi |
||||
NV |
||||
United States |
||||
5 |
||||
United StatesPing Liu |
||||
$71,614 |
||||
406.8 |
||||
Chicago |
||||
IL |
||||
United States |
||||
6 |
||||
CanadaDaniel Negreanu |
||||
$52,099 |
||||
379.7 |
||||
Toronto |
||||
ON |
||||
Canada |
||||
7 |
||||
NetherlandsMartijn Gerrits |
||||
$38,823 |
||||
325.4 |
||||
- |
||||
- |
||||
Netherlands |
||||
8 |
||||
United StatesZach Clark |
||||
$29,650 |
||||
298.3 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
9 |
||||
United StatesCary Katz |
||||
$23,224 |
||||
271.2 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
10 |
||||
United StatesAnatoly Filatov |
||||
$18,667 |
||||
217.0 |
||||
Blue Point |
||||
NY |
||||
United States |
||||
11 |
||||
United StatesDarren Elias |
||||
$18,667 |
||||
217.0 |
||||
Philadelphia |
||||
PA |
||||
United States |
||||
12 |
||||
United StatesDaniel Zack |
||||
$18,667 |
||||
217.0 |
||||
Princeton |
||||
NJ |
||||
United States |
||||
13 |
||||
United StatesBen Lamb |
||||
$15,408 |
||||
217.0 |
||||
Henderson |
||||
NV |
||||
United States |
||||
14 |
||||
United StatesBen Yu |
||||
$15,408 |
||||
217.0 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
15 |
||||
FranceBenjamin Pollak |
||||
$15,408 |
||||
108.5 |
||||
Paris |
||||
- |
||||
France |
||||
16 |
||||
United StatesNick Schulman |
||||
$13,070 |
||||
108.5 |
||||
New York |
||||
NY |
||||
United States |
||||
17 |
||||
GermanyManig Loeser |
||||
$13,070 |
||||
108.5 |
||||
Bad Homburg |
||||
- |
||||
Germany |
||||
18 |
||||
United StatesCraig Varnell |
||||
$13,070 |
||||
108.5 |
||||
Ft Collins |
||||
CO |
||||
United States |
||||
19 |
||||
United StatesByron Kaverman |
||||
$11,402 |
||||
108.5 |
||||
Fort Jennings |
||||
OH |
||||
United States |
||||
20 |
||||
PortugalManuel Afonso Soares Ruivo |
||||
$11,402 |
||||
108.5 |
||||
Coimbra |
||||
- |
||||
Portugal |
||||
21 |
||||
United StatesDavid Benyamine |
||||
$11,402 |
||||
54.2 |
||||
Henderson |
||||
NV |
||||
United States |
||||
22 |
||||
United StatesDan Shak |
||||
$11,402 |
||||
54.2 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
23 |
||||
ChinaYong Wang |
||||
$11,402 |
||||
54.2 |
||||
- |
||||
- |
||||
China |
||||
24 |
||||
United StatesArkadiy Tsinis |
||||
$11,402 |
||||
54.2 |
||||
Miami |
||||
FL |
||||
United States |
||||
25 |
||||
United StatesErik Seidel |
||||
$11,402 |
||||
54.2 |
||||
Henderson |
||||
NV |
||||
United States |
||||
26 |
||||
United KingdomToby Lewis |
||||
$11,402 |
||||
54.2 |
||||
Southampton |
||||
- |
||||
United Kingdom |
||||
27 |
||||
United StatesMohsin Charania |
||||
$11,402 |
||||
54.2 |
||||
Chicago |
||||
IL |
||||
United States |
||||
28 |
||||
United StatesBen Palmer |
||||
$10,238 |
||||
54.2 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
29 |
||||
AustriaAndreas Eiler |
||||
$10,238 |
||||
54.2 |
||||
Scharding |
||||
- |
||||
Austria |
||||
30 |
||||
United StatesThai Ha |
||||
$10,238 |
||||
54.2 |
||||
Factoryville |
||||
PA |
||||
United States |
||||
31 |
||||
United KingdomMatas Cimbolas |
||||
$10,238 |
||||
54.2 |
||||
London |
||||
- |
||||
United Kingdom |
||||
@ -1,217 +0,0 @@ |
||||
1 |
||||
United StatesBrian Green |
||||
$345,669 |
||||
1,084.8 |
||||
Decatur |
||||
TX |
||||
United States |
||||
2 |
||||
United StatesAli Imsirovic |
||||
$213,644 |
||||
542.4 |
||||
Vancouver |
||||
WA |
||||
United States |
||||
3 |
||||
United StatesAsher Conniff |
||||
$145,097 |
||||
488.2 |
||||
Brooklyn |
||||
NY |
||||
United States |
||||
4 |
||||
United StatesLoren Klein |
||||
$100,775 |
||||
433.9 |
||||
Verdi |
||||
NV |
||||
United States |
||||
5 |
||||
United StatesPing Liu |
||||
$71,614 |
||||
406.8 |
||||
Chicago |
||||
IL |
||||
United States |
||||
6 |
||||
CanadaDaniel Negreanu |
||||
$52,099 |
||||
379.7 |
||||
Toronto |
||||
ON |
||||
Canada |
||||
7 |
||||
NetherlandsMartijn Gerrits |
||||
$38,823 |
||||
325.4 |
||||
- |
||||
- |
||||
Netherlands |
||||
8 |
||||
United StatesZach Clark |
||||
$29,650 |
||||
298.3 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
9 |
||||
United StatesCary Katz |
||||
$23,224 |
||||
271.2 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
10 |
||||
United StatesAnatoly Filatov |
||||
$18,667 |
||||
217.0 |
||||
Blue Point |
||||
NY |
||||
United States |
||||
11 |
||||
United StatesDarren Elias |
||||
$18,667 |
||||
217.0 |
||||
Philadelphia |
||||
PA |
||||
United States |
||||
12 |
||||
United StatesDaniel Zack |
||||
$18,667 |
||||
217.0 |
||||
Princeton |
||||
NJ |
||||
United States |
||||
13 |
||||
United StatesBen Lamb |
||||
$15,408 |
||||
217.0 |
||||
Henderson |
||||
NV |
||||
United States |
||||
14 |
||||
United StatesBen Yu |
||||
$15,408 |
||||
217.0 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
15 |
||||
FranceBenjamin Pollak |
||||
$15,408 |
||||
108.5 |
||||
Paris |
||||
- |
||||
France |
||||
16 |
||||
United StatesNick Schulman |
||||
$13,070 |
||||
108.5 |
||||
New York |
||||
NY |
||||
United States |
||||
17 |
||||
GermanyManig Loeser |
||||
$13,070 |
||||
108.5 |
||||
Bad Homburg |
||||
- |
||||
Germany |
||||
18 |
||||
United StatesCraig Varnell |
||||
$13,070 |
||||
108.5 |
||||
Ft Collins |
||||
CO |
||||
United States |
||||
19 |
||||
United StatesByron Kaverman |
||||
$11,402 |
||||
108.5 |
||||
Fort Jennings |
||||
OH |
||||
United States |
||||
20 |
||||
PortugalManuel Afonso Soares Ruivo |
||||
$11,402 |
||||
108.5 |
||||
Coimbra |
||||
- |
||||
Portugal |
||||
21 |
||||
United StatesDavid Benyamine |
||||
$11,402 |
||||
54.2 |
||||
Henderson |
||||
NV |
||||
United States |
||||
22 |
||||
United StatesDan Shak |
||||
$11,402 |
||||
54.2 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
23 |
||||
ChinaYong Wang |
||||
$11,402 |
||||
54.2 |
||||
- |
||||
- |
||||
China |
||||
24 |
||||
United StatesArkadiy Tsinis |
||||
$11,402 |
||||
54.2 |
||||
Miami |
||||
FL |
||||
United States |
||||
25 |
||||
United StatesErik Seidel |
||||
$11,402 |
||||
54.2 |
||||
Henderson |
||||
NV |
||||
United States |
||||
26 |
||||
United KingdomToby Lewis |
||||
$11,402 |
||||
54.2 |
||||
Southampton |
||||
- |
||||
United Kingdom |
||||
27 |
||||
United StatesMohsin Charania |
||||
$11,402 |
||||
54.2 |
||||
Chicago |
||||
IL |
||||
United States |
||||
28 |
||||
United StatesBen Palmer |
||||
$10,238 |
||||
54.2 |
||||
Las Vegas |
||||
NV |
||||
United States |
||||
29 |
||||
AustriaAndreas Eiler |
||||
$10,238 |
||||
54.2 |
||||
Scharding |
||||
- |
||||
Austria |
||||
30 |
||||
United StatesThai Ha |
||||
$10,238 |
||||
54.2 |
||||
Factoryville |
||||
PA |
||||
United States |
||||
31 |
||||
United KingdomMatas Cimbolas |
||||
$10,238 |
||||
54.2 |
||||
London |
||||
- |
||||
United Kingdom |
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,28 @@ |
||||
// |
||||
// ChipCount.swift |
||||
// TournamentStats |
||||
// |
||||
// Created by Laurent Morvillier on 27/06/2019. |
||||
// Copyright © 2019 Stax River. All rights reserved. |
||||
// |
||||
|
||||
import Foundation |
||||
|
||||
struct ChipCountManager { |
||||
|
||||
var chipCounts: [ChipCount] |
||||
var totalChips: Double |
||||
|
||||
} |
||||
|
||||
struct ChipCount { |
||||
|
||||
var player: String |
||||
var chips: Double |
||||
|
||||
func percentage(totalChips: Double) -> String { |
||||
let percentage = self.chips / totalChips * 100 |
||||
return "\(percentage)%" |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue