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

+- Sick Gaming (https://www.sickgaming.net)
+-- Forum: Programming (https://www.sickgaming.net/forum-76.html)
+--- Forum: Python (https://www.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

<div>
<div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload="{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;555866&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;0&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;0&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;0\/5 - (0 votes)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;0&quot;,&quot;_legend&quot;:&quot;{score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}">
<div class="kksr-stars">
<div class="kksr-stars-inactive">
<div class="kksr-star" data-star="1" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="2" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="3" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="4" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="5" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
<div class="kksr-stars-active" style="width: 0px;">
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
</div>
<div class="kksr-legend" style="font-size: 19.2px;"> <span class="kksr-muted">Rate this post</span> </div>
</div>
<h2 id="bf1b">Step 1: Install csv-ical Module with PIP</h2>
<p>Run the following command in your command line or PowerShell (Windows) or shell or terminal (macOS, Linux, Ubuntu) to install the <code><a href="https://github.com/albertyw/csv-ical" data-type="URL" data-id="https://github.com/albertyw/csv-ical" target="_blank" rel="noreferrer noopener">csv-ical</a></code> library:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install csv-ical</pre>
<p>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.</p>
<p class="has-global-color-8-background-color has-background"><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f30d.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Full Guide</strong>: <a rel="noreferrer noopener" href="https://blog.finxter.com/installing-specific-package-versions-with-pip/" data-type="post" data-id="320873" target="_blank">How to install a library/module in Python?</a></p>
<h2 id="2602">Step 2: Prepare files</h2>
<p id="751d">Create a new Python code file with the extension <code>.py</code> or a Jupyter Notebook with the file extension <code>.ipynb</code>. This creates a Python script or Jupyter Notebook that can run the code in Step 3 to conver the <code>.ics</code>.</p>
<p>Now, put the <code>.ics</code> file to be converted in the same folder as the newly-created Python script. </p>
<p id="751d">Use Jupyter Notebook to create a new <code>.ipynb</code> file</p>
<h2 id="de7d">Step 3: Convert</h2>
<p>This step consists of running the code doing these three things:</p>
<ul>
<li>Create and initialize a <code>Convert</code> object</li>
<li>Read the <code>.ics</code> file</li>
<li>Create the CSV object and save it at the specified location</li>
</ul>
<p>Here’s the full code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">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)</pre>
</p>
<p>Thanks for going through the whole tutorial! &lt;3</p>
<hr class="wp-block-separator has-alpha-channel-opacity"/>
</div>


https://www.sickgaming.net/blog/2022/08/08/3-simple-steps-to-convert-calendar-ics-to-csv-excel-in-python/