# Python Learning Tips - Laser Focused on CSV Data Processing

**URL:** <https://discuss.python.org/t/python-learning-tips-laser-focused-on-csv-data-processing/36837>\
**Category:** Python Help\
**Created:** [October 21, 2023, 10:30pm UTC](https://discuss.python.org/t/python-learning-tips-laser-focused-on-csv-data-processing/36837 "2023-10-21T22:30:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [October 22, 2023, 12:42am UTC](https://discuss.python.org/t/python-learning-tips-laser-focused-on-csv-data-processing/36837/2 "2023-10-22T00:42:52Z")

</div>

You can split a filename with the .split method `filename.split("_")`. That’ll give you the DB# and the remainder.

A useful string method is `.endswith`, and you can split just once on at the end with `filename.rsplit(".", 1)`.

I’d also suggest judicious use of `dict` and maybe `defaultdict` to store and categorise the filenames. You can use one to group all the filenames by DB #, for example, and then process all those having the same DB #.

---

_[View the full topic](https://discuss.python.org/t/python-learning-tips-laser-focused-on-csv-data-processing/36837)._
