<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def analyze_feature(raw_datasets, feature, basename="aspect_ratios"):
 """ Apply ``feature`` to all recordings in ``raw_datasets``. Store the results in two files. One file stores the raw result, the other one groups the results by symbols and stores the mean, standard deviation and the name of the symbol as a csv file. Parameters raw_datasets : List of dictionaries Each dictionary is a raw_dataset. feature : An instance of the feature class type The `feature` which gets analyzed on `raw_datasets`. basename : string Name for the file in which the data gets written. """


    # Prepare files
    csv_file = dam.prepare_file(basename + '.csv')
    raw_file = dam.prepare_file(basename + '.raw')

    csv_file = open(csv_file, 'a')
    raw_file = open(raw_file, 'a')

    csv_file.write("label,mean,std\n")  # Write header
    raw_file.write("latex,raw_data_id,value\n")  # Write header

    print_data = []
    for _, datasets in dam.sort_by_formula_id(raw_datasets).items():
        values = []
        for data in datasets:
            value = feature(data)[0]
            values.append(value)
            raw_file.write("%s,%i,%0.2f\n" % (datasets[0].formula_in_latex,
                                              data.raw_data_id,
                                              value))
        label = filter_label(datasets[0].formula_in_latex)
        print_data.append((label, numpy.mean(values), numpy.std(values)))

    # Sort the data by highest mean, descending
    print_data = sorted(print_data, key=lambda n: n[1], reverse=True)

    # Write data to file
    for label, mean, std in print_data:
        csv_file.write("%s,%0.2f,%0.2f\n" % (label, mean, std))
    csv_file.close()