Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No documentation about parsing #152

Closed
enkidulan opened this issue Nov 22, 2014 · 6 comments · Fixed by #547
Closed

No documentation about parsing #152

enkidulan opened this issue Nov 22, 2014 · 6 comments · Fixed by #547
Labels
good first issue hacktoberfest Issues for participation in the hacktoberfest https://hacktoberfest.com/

Comments

@enkidulan
Copy link

First of all thank you for this awesome package.
I have read documentation and haven't found any information about how to parse ical files, and that is quite confusing. It would be just great if you add some parsing examples into docs. I found a lot of examples how to use icalendar here - http://stackoverflow.com/questions/3408097/parsing-files-ics-icalendar-using-python.
Thank you.

@thet
Copy link
Member

thet commented Nov 24, 2014

You should also have a look at the tests, like this one: https://github.com/collective/icalendar/blob/master/src/icalendar/tests/test_timezoned.py

But I agree, documentation could be better. Contributions welcome :)

@danstowell
Copy link

FWIW I put together a simple script using icalendar to render ical to html. It may be useful as a source of example material https://github.com/danstowell/calendrino

@jnikula
Copy link

jnikula commented Apr 2, 2018

Please try to find some time to put together even rudimentary documentation about parsing. Basically I've initially disregarded the whole package because I've thought there isn't proper support for parsing. The tests aren't documentation, and they aren't even good examples of how this should be used.

I'm trying to like this, but it's tough going having to read the source to get this right...

@nicbou
Copy link

nicbou commented Jan 11, 2022

This is still an issue in 2021. The documentation is very sparse, and doesn't cover basic use cases like parsing an iCalendar file (for instance from a Google Calendar export).

@jnikula
Copy link

jnikula commented Jan 11, 2022

This is still an issue in 2022.

FTFY. ;)

@nicbou
Copy link

nicbou commented Jan 11, 2022

Ha! Good catch!

I got it working. Here's a little code sample to get you started. It should be here when the code is committed and pushed some time in the next few days.

with open(ics_file, 'r') as file:
    calendar = Calendar.from_ical(file.read())
    for event in calendar.walk('VEVENT'):
        event_metadata = {
            'event': {
                'end_date': datetime_to_json(event['DTEND'].dt)
            }
        }

        if event.get('LOCATION'):
            event_metadata['location'] = {
                'name': event['LOCATION']
            }

        if event.get('DTSTAMP'):
            event_metadata['event']['creation_date'] = datetime_to_json(event['DTSTAMP'].dt)

        # ...

@niccokunzmann niccokunzmann added good first issue hacktoberfest Issues for participation in the hacktoberfest https://hacktoberfest.com/ labels Aug 30, 2023
niccokunzmann added a commit to niccokunzmann/icalendar that referenced this issue Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue hacktoberfest Issues for participation in the hacktoberfest https://hacktoberfest.com/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants