Sick Gaming
[Tut] 3 Simple Steps to Convert calendar.ics to CSV/Excel in Python - Printable Version

+- Sick Gaming (https://sickgaming.net)
+-- Forum: Programming (https://sickgaming.net/forum-76.html)
+--- Forum: Python (https://sickgaming.net/forum-83.html)
+--- Thread: [Tut] 3 Simple Steps to Convert calendar.ics to CSV/Excel in Python (/thread-99796.html)



[Tut] 3 Simple Steps to Convert calendar.ics to CSV/Excel in Python - xSicKxBot - 08-12-2022

3 Simple Steps to Convert calendar.ics to CSV/Excel in Python

Rate this post

Step 1: Install csv-ical Module with PIP

Run the following command in your command line or PowerShell (Windows) or shell or terminal (macOS, Linux, Ubuntu) to install the
Code:
csv-ical
library:

Code:
pip install csv-ical

In some instances, you need to modify this command a bit to make it work. If you need more assistance installing the library, check out my detailed guide.

[Image: 1f30d.png] Full Guide: How to install a library/module in Python?

Step 2: Prepare files

Create a new Python code file with the extension
Code:
.py
or a Jupyter Notebook with the file extension
Code:
.ipynb
. This creates a Python script or Jupyter Notebook that can run the code in Step 3 to conver the
Code:
.ics
.

Now, put the
Code:
.ics
file to be converted in the same folder as the newly-created Python script.

Use Jupyter Notebook to create a new
Code:
.ipynb
file

Step 3: Convert

This step consists of running the code doing these three things:
  • Create and initialize a
    Code:
    Convert
    object

  • Read the
    Code:
    .ics
    file

  • Create the CSV object and save it at the specified location

Here’s the full code:

Code:
from csv_ical import Convert # Create and initialize a Convert object convert = Convert() convert.CSV_FILE_LOCATION = 'my_file.csv' convert.SAVE_LOCATION = 'my_file.ics' # Read the .ics file convert.read_ical(convert.SAVE_LOCATION) # Create the CSV object and save it at the specified location convert.make_csv() convert.save_csv(convert.CSV_FILE_LOCATION)

Thanks for going through the whole tutorial! <3