Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pruefungseinsicht-calendly-export
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Das Gupta
pruefungseinsicht-calendly-export
Commits
b9240a87
Commit
b9240a87
authored
4 years ago
by
Florian Bruhin
Browse files
Options
Downloads
Patches
Plain Diff
Initial preparation for xlsx output
parent
607c6ae4
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
export.py
+32
-23
32 additions, 23 deletions
export.py
with
32 additions
and
23 deletions
export.py
+
32
−
23
View file @
b9240a87
import
csv
import
openpyxl
import
collections
import
os.path
...
...
@@ -6,16 +7,12 @@ def process(reader):
event_data
=
collections
.
defaultdict
(
list
)
for
line
in
reader
:
date
,
time
=
line
[
'
Start Date & Time
'
].
split
(
'
'
)
if
time
==
'
12:15
'
:
timename
=
'
Mittag
'
elif
time
==
'
17:30
'
:
timename
=
'
Abend
'
else
:
raise
ValueError
(
time
)
filename
=
f
'
{
date
}
_
{
timename
}
.csv
'
exams
=
line
[
'
Response 1
'
].
split
(
'
\n
'
)
+
line
[
'
Response 2
'
].
split
(
'
\n
'
)
date
,
slot
=
line
[
'
Start Date & Time
'
].
split
(
'
'
)
# FIXME
slot
=
f
'
{
date
}
{
slot
}
'
# assert date == ...
exams
=
line
[
'
Response 1
'
].
split
(
'
\n
'
)
+
line
[
'
Response 2
'
].
split
(
'
\n
'
)
# fixme 3 and 4
exams
=
[
e
for
e
in
exams
if
e
]
lastname
=
line
[
'
Invitee Last Name
'
]
...
...
@@ -23,29 +20,41 @@ def process(reader):
email
=
line
[
'
Invitee Email
'
]
if
line
[
'
Canceled
'
]
==
'
true
'
:
print
(
f
"
Cancelled:
{
lastname
}
{
firstname
}
for
{
date
}
{
timename
}
"
)
print
(
f
"
Cancelled:
{
lastname
}
{
firstname
}
for
{
slot
}
"
)
continue
if
not
firstname
or
not
lastname
:
print
(
f
"
!!! WRONG NAME:
{
lastname
}
{
firstname
}
{
email
}
for
{
date
}
{
timename
}
{
exams
}
"
)
print
(
f
"
!!! WRONG NAME:
{
lastname
}
{
firstname
}
{
email
}
for
{
slot
}
{
exams
}
"
)
if
not
exams
:
print
(
f
"
!!! NO EXAMS:
{
lastname
}
{
firstname
}
{
email
}
for
{
date
}
{
timename
}
"
)
print
(
f
"
!!! NO EXAMS:
{
lastname
}
{
firstname
}
{
email
}
for
{
slot
}
"
)
event_data
[
filename
].
append
((
lastname
,
firstname
,
'
'
.
join
(
exams
),
email
))
event_data
[
slot
].
append
((
lastname
,
firstname
,
'
'
.
join
(
exams
),
email
))
return
event_data
def
writeout
(
filename
,
data
):
with
open
(
filename
,
'
w
'
,
newline
=
''
,
encoding
=
'
latin1
'
)
as
f
:
writer
=
csv
.
writer
(
f
,
delimiter
=
'
;
'
)
date
,
timename
=
os
.
path
.
splitext
(
filename
)[
0
].
split
(
'
_
'
)
writer
.
writerow
([
date
,
timename
,
''
,
''
])
def
_resize_cols
(
sheet
):
dimensions
=
{
'
A
'
:
20
,
'
B
'
:
20
,
'
C
'
:
50
,
'
D
'
:
30
,
}
for
col
,
dim
in
dimensions
.
items
():
sheet
.
column_dimensions
[
col
].
width
=
dim
def
writeout
(
event_data
):
workbook
=
openpyxl
.
Workbook
()
for
slot
,
data
in
event_data
.
items
():
sheet
=
workbook
.
create_sheet
(
title
=
slot
.
replace
(
'
:
'
,
'
.
'
))
for
row
in
data
:
writer
.
writerow
(
list
(
row
))
sheet
.
append
(
list
(
row
))
_resize_cols
(
sheet
)
del
workbook
[
'
Sheet
'
]
workbook
.
save
(
'
einsicht.xlsx
'
)
with
open
(
'
events-export.csv
'
)
as
f
:
reader
=
csv
.
DictReader
(
f
)
all_data
=
process
(
reader
)
for
filename
,
data
in
all_data
.
items
():
writeout
(
filename
,
data
)
event_data
=
process
(
reader
)
writeout
(
event_data
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment