It depends on what criterion you want to show/hide a category. Perhaps you have a look first at my sitenavigation block just finished for Moodle 2.3
If you are bothering about NAVIGATION matter, then you simply need a good block showing what ever you want to show/hide and you could take my sitenavigation code to do so.
But the original post here was to completely disable access either to courses you list in a CSV file or the categories they are in.
So the last is a completely different pair of shoes and needs a completely other approach. Whereas my sitenavigation block does only sort of fata morgana, simply not displaying things to users. If users know the urls, they could still access the objects in the database. E.g. in my block you can show/hide active, inactive and "old" courses you did not visit for a given number of days. But if you click on the SHOW ALL COURSES link in my block or you simply call the url yourmoodle.com/course/index.php, then everybody can still see/access every category and every course in it.
So if you really want to prevent the users from accessing anything in the database either you really remove it from the database (and insert it just in time you need it) or you need other bits/criterions you can save/set in the database to prevent users from accessing courses/categories/etc. either by setting up given dates or show/hide flags.