Session Ready
Exercise

Does it even exist?

Your a social media company with a huge problem. Your NoSQL database cluster was upgraded to 1.0.0-beta because it had some really cool new features. Around this same time files started disappearing in production and social media posts were suddenly vanishing. It turns out the beta version of the database was actually deleting data between cluster nodes, not syncing data. Even worse, the backups were never tested and the same backup from a year previous was being run over and over again. You have a list of all social media posts that should exist in production, and you need to write a script that audits which files actually exist.

Write a script using pathlib that validates if a list of files exists on disk. Remember you can explore pathlib.Path in IPython.

Instructions
100 XP
  • Read in a posts_index.txt file to find paths.
  • Create pathlib.Path objects and use .exists() to check if the path is valid.
  • Use post.strip() to clean up the output of path you pass to pathlib.Post.