📅 2023-01-20 — Session: Enhanced Python scripting and file handling techniques
🕒 16:50–18:10
🏷️ Labels: Python, File Handling, Ipython, Automation, Scripting
📂 Project: Dev
⭐ Priority: MEDIUM
Session Goal
The session aimed to enhance Python scripting skills, focusing on file handling, automation, and code organization in IPython notebooks.
Key Activities
- File Listing with
glob.glob()
: Explored how to list files containing specific substrings in their names using theglob
module. - Yearly Automation with For Loops: Demonstrated executing commands over multiple years using
for
loops. - Optimizing Directory Management: Discussed best practices for managing working directories in loops using
os.chdir()
. - Extracting Substrings from Filenames: Illustrated methods for extracting years from filenames using regular expressions and string slicing.
- Saving and Reporting DataFrames: Provided a method to save pandas DataFrames to CSV files with size reporting.
- Human-Readable File Sizes: Introduced the
humanize
library for formatting file sizes. - Variable Management in IPython: Explained defining and importing variables from external Python files into IPython notebooks.
Achievements
- Gained insights into efficient file handling and directory management in Python scripts.
- Learned techniques for automating tasks over multiple years.
- Improved skills in organizing code and managing variables in IPython notebooks.
Pending Tasks
- Explore additional libraries for file handling and automation.
- Implement learned techniques in a real-world project to assess their effectiveness.