<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def readDir(dirPath, numLabels, modify=False):
 """ Reads in data from a directory of CSV files; assumes the directory only contains CSV files. @param dirPath (str) Path to the directory. @param numLabels (int) Number of columns of category labels. @param modify (bool) Map the unix friendly category names to the actual names. 0 -> /, _ -> " " @return samplesDict (defaultdict) Keys are CSV names, values are OrderedDicts, where the keys/values are as specified in readCSV(). """

  samplesDict = defaultdict(list)
  for _, _, files in os.walk(dirPath):
    for f in files:
      basename, extension = os.path.splitext(os.path.basename(f))
      if "." in basename and extension == ".csv":
        category = basename.split(".")[-1]
        if modify:
          category = category.replace("0", "/")
          category = category.replace("_", " ")
        samplesDict[category] = readCSV(
          os.path.join(dirPath, f), numLabels=numLabels)

  return samplesDict