Brackets

Check-in [461ec95f53]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:add div name to div sheets
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:461ec95f5349673d54b845f44fe93d4e4f06c77a6c4eeb70f722a6a3cb433f6d
User & Date: scott 2018-03-22 03:12:33
Context
2018-03-22
06:23
starting next section check-in: ebb1395d47 user: scott tags: trunk
03:12
add div name to div sheets check-in: 461ec95f53 user: scott tags: trunk
01:15
made it work check-in: 69a933c607 user: scott tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Bracket-Builder.py.

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
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
    return lst.count(x) + sum(nested_count(l,x) for l in lst if isinstance(l,list))
'''

def csv_import(csv_fname):
    # This function will import the data from the CSV file and return it as a global variable as well as other instantiations
    divisions = []
    athleteCountByDivision = []

    # This section reads in a CSV file
    with open(csv_fname, 'r') as f:
        csv_input = csv.reader(f, dialect='excel', delimiter=",")
        athlete_feed_data_csv = tuple(csv_input)
    # this section sets all of the divisions into a tuple  
    for aclass in athlete_feed_data_csv:
            t = aclass[0] 
            if t not in divisions:
                divisions.append(t)
#    divisions = tuple(divisions)
    # Identify Divisions and Athlete Count
    counter = collections.Counter(itertools.chain(*athlete_feed_data_csv))

    for div_name in divisions:
        c = counter[div_name]
        x = [div_name, c]
        athleteCountByDivision.append(x)











    return athlete_feed_data_csv, divisions, athleteCountByDivision

def main(args):
#the main program that makes everything work

#feed in filename of csv file in base path
    csv_fname = input("Enter the name of the CSV File: ")
    if csv_fname == "":
        csv_fname = 'F:\Python-Dev\Brackets-Nationals\sample1-bxlist.csv'
    athlete_feed_data_csv, divisions, athleteCountByDivision = csv_import(csv_fname)
    docbuild = sheet_build(athlete_feed_data_csv, divisions, athleteCountByDivision)

    return 0 

def sheet_build(athlete_feed_data_csv, divisions, athleteCountByDivision):
    import pyoo
    # Stuff around opening up a sheet and feeding in data
    desktop = pyoo.Desktop('localhost', 2002)
    doc = desktop.open_spreadsheet('F:\Python-Dev\Brackets-Nationals\Bracket-template.ods')
    #doc = desktop.create_spreadsheet()

    # Create all of the worksheets and populate with basic information
    get_sheet_name = pyoo.NameGenerator()
    sheetNames = []
    for dname in divisions:
        doc.sheets.copy('Bracket-Template', get_sheet_name(dname))
        # libreoffice tab length is 31 characters, this will correct this but still put in full name
        t = dname[:31]
        sheetNames.append(t)

    #Broken above, not getting the counts in the nested list




    # Enter all of the divisions with # of athletes into the DivCounts Sheet
    DivCountsSheet = doc.sheets['DivCounts']
    rstart = 1
    cstart = 0
    rstop = len(athleteCountByDivision) + rstart
    cstop = len(athleteCountByDivision[0]) + cstart
    DivCountsSheet[rstart:rstop, cstart:cstop].values = athleteCountByDivision
................................................................................
    # Geometry set for putting data in the startlist (counting starts at 0; r is row and c is column)
    rstart = 3
    cstart = 0
    rstop = len(athlete_feed_data_csv) + rstart
    cstop = len(athlete_feed_data_csv[0]) + cstart
    alist[rstart:rstop, cstart:cstop].values = athlete_feed_data_csv

    return doc

def wavecount():
    #This will identify how many waves for the # of athletes including how many LCQ spots
    pass

def heatshape(waves):
    startrow = 0







>












>




<
>
>
>
>
>
>
>
>
>
>
|








|
|
<


|









|





|
>
>
>
>







 







|







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
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    return lst.count(x) + sum(nested_count(l,x) for l in lst if isinstance(l,list))
'''

def csv_import(csv_fname):
    # This function will import the data from the CSV file and return it as a global variable as well as other instantiations
    divisions = []
    athleteCountByDivision = []
    tabNames = []
    # This section reads in a CSV file
    with open(csv_fname, 'r') as f:
        csv_input = csv.reader(f, dialect='excel', delimiter=",")
        athlete_feed_data_csv = tuple(csv_input)
    # this section sets all of the divisions into a tuple  
    for aclass in athlete_feed_data_csv:
            t = aclass[0] 
            if t not in divisions:
                divisions.append(t)
#    divisions = tuple(divisions)
    # Identify Divisions and Athlete Count
    counter = collections.Counter(itertools.chain(*athlete_feed_data_csv))
    #Found out how many athletes per division
    for div_name in divisions:
        c = counter[div_name]
        x = [div_name, c]
        athleteCountByDivision.append(x)

    for tab_name in divisions:
        divlist = tab_name.split(" ")
        if '&' in divlist:
            divlist[divlist.index('&')] = 'and'
        if divlist[0] == 'Snowboard':
            x = ["SB"] + divlist[1:]
        if divlist[0] == 'Freeski':
            x = ["FS"] + divlist[1:]
        x = " ".join(x)
        tabNames.append(x) 
    return athlete_feed_data_csv, divisions, athleteCountByDivision, tabNames

def main(args):
#the main program that makes everything work

#feed in filename of csv file in base path
    csv_fname = input("Enter the name of the CSV File: ")
    if csv_fname == "":
        csv_fname = 'F:\Python-Dev\Brackets-Nationals\sample1-bxlist.csv'
    athlete_feed_data_csv, divisions, athleteCountByDivision, tabNames = csv_import(csv_fname)
    docbuild = sheet_build(athlete_feed_data_csv, divisions, athleteCountByDivision, tabNames)

    return 0 

def sheet_build(athlete_feed_data_csv, divisions, athleteCountByDivision, tabNames):
    import pyoo
    # Stuff around opening up a sheet and feeding in data
    desktop = pyoo.Desktop('localhost', 2002)
    doc = desktop.open_spreadsheet('F:\Python-Dev\Brackets-Nationals\Bracket-template.ods')
    #doc = desktop.create_spreadsheet()

    # Create all of the worksheets and populate with basic information
    get_sheet_name = pyoo.NameGenerator()
    sheetNames = []
    for dname in tabNames:
        doc.sheets.copy('Bracket-Template', get_sheet_name(dname))
        # libreoffice tab length is 31 characters, this will correct this but still put in full name
        t = dname[:31]
        sheetNames.append(t)

    #Put division name in the B1 cell of each sheet.
    for dname in tabNames:
        tsheet = doc.sheets[dname]
        tsheet[0,1].value = dname
    
    # Enter all of the divisions with # of athletes into the DivCounts Sheet
    DivCountsSheet = doc.sheets['DivCounts']
    rstart = 1
    cstart = 0
    rstop = len(athleteCountByDivision) + rstart
    cstop = len(athleteCountByDivision[0]) + cstart
    DivCountsSheet[rstart:rstop, cstart:cstop].values = athleteCountByDivision
................................................................................
    # Geometry set for putting data in the startlist (counting starts at 0; r is row and c is column)
    rstart = 3
    cstart = 0
    rstop = len(athlete_feed_data_csv) + rstart
    cstop = len(athlete_feed_data_csv[0]) + cstart
    alist[rstart:rstop, cstart:cstop].values = athlete_feed_data_csv

    return 0

def wavecount():
    #This will identify how many waves for the # of athletes including how many LCQ spots
    pass

def heatshape(waves):
    startrow = 0