<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract_profiles(self, pipeline_name, expose_data=True):
 """ Extract all the profiles of a specific pipeline and exposes the data in the namespace """

        compas_pipe = self.__profile_definition(pipeline_name)
        get_variable = compas_pipe.GEtUserVariable
        if os.path.isdir(self.path+'profiles') is not True:
            os.mkdir(self.path + 'profiles')
        target_dir = self.path + 'profiles'
        if expose_data is True:
            self.profiles[pipeline_name] = {}
        for key in PROFILE_KEYS:
            pipe = self.pipes[pipeline_name]
            pipe['data'][key] = get_variable(PROFILE_KEYS[key]).Variable()
            temp = {key: val for (key, val) in enumerate(pipe['data'][key])}
            try:
                data = pd.DataFrame(temp, index=pipe['grid'])
            except ValueError:
                data = pd.DataFrame(temp, index=pipe['non_st_grid'])
            data.columns = self.pipes[pipeline_name]['timesteps']
            data.to_csv('{}/{}-{}.csv'.format(target_dir, pipeline_name, key))
            if expose_data is True:
                self.profiles[pipeline_name][key] = data