Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tarik Graba
csv2ics
Commits
17baff68
Commit
17baff68
authored
Aug 23, 2019
by
Tarik Graba
😷
Browse files
Add command line arguments to specify in and out filenames
parent
d2a62705
Changes
1
Hide whitespace changes
Inline
Side-by-side
csv2ics.py
View file @
17baff68
...
@@ -4,16 +4,38 @@ from icalendar import Calendar, Event
...
@@ -4,16 +4,38 @@ from icalendar import Calendar, Event
from
datetime
import
datetime
from
datetime
import
datetime
from
pytz
import
timezone
from
pytz
import
timezone
# Parse arguments
import
argparse
parser
=
argparse
.
ArgumentParser
()
CSV_FNAME
=
'PACT.csv'
requiredArgs
=
parser
.
add_argument_group
(
'required named arguments'
)
ICS_FNAME
=
'PACT.ics'
requiredArgs
.
add_argument
(
"-i"
,
"--csv"
,
help
=
"input csv file"
,
required
=
True
)
requiredArgs
.
add_argument
(
"-o"
,
"--ics"
,
help
=
"output ics file"
,
required
=
True
)
parser
.
add_argument
(
"-c"
,
"--summary"
,
help
=
"summary that will be added to the ics, otherwise, the input file name is usted"
,
required
=
False
)
args
=
parser
.
parse_args
()
CSV_FNAME
=
args
.
csv
ICS_FNAME
=
args
.
ics
if
args
.
summary
:
SUMMARY
=
args
.
summary
else
:
# The name of the CSV files generated by Synapses are informative
import
os
SUMMARY
=
os
.
path
.
splitext
(
os
.
path
.
basename
(
CSV_FNAME
))[
0
]
# Conversion
date_fmt
=
"%d/%m/%Y %H:%M"
date_fmt
=
"%d/%m/%Y %H:%M"
date_locale
=
timezone
(
'Europe/Paris'
)
date_locale
=
timezone
(
'Europe/Paris'
)
cal
=
Calendar
()
cal
=
Calendar
()
cal
[
'summary'
]
=
'EDT PACT'
cal
[
'summary'
]
=
SUMMARY
with
open
(
CSV_FNAME
)
as
csvfile
:
with
open
(
CSV_FNAME
)
as
csvfile
:
seances
=
csv
.
reader
(
csvfile
,
delimiter
=
';'
,
quotechar
=
'"'
)
seances
=
csv
.
reader
(
csvfile
,
delimiter
=
';'
,
quotechar
=
'"'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment