<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_csv(weekmatrices, filename, digits=5):
 """ Exports a list of week-matrices to a specified filename in the CSV format. Parameters weekmatrices : list The week-matrices to export. filename : string Path for the exported CSV file. """


    with open(filename, 'w') as f:
        w = csv.writer(f, lineterminator='\n')
        w.writerow(['year_week', 'channel', 'weekday', 'section', 'value'])

        def make_repr(item):
            if item is None:
                return None
            elif isinstance(item, float):
                return repr(round(item, digits))
            else:
                return str(item)

        for row in weekmatrices:
            w.writerow([make_repr(item) for item in row])