Write a fixed-length to comma-separated text parser.
Implement parse_fixed_width(text, field_lengths). The input contains newline-separated fixed-width records, and field_lengths gives each field width in order. Return one comma-separated record per input line, trimming surrounding spaces from fields and escaping fields that contain commas or double quotes using standard CSV rules. Records are valid and each line has a length equal to the sum of the field widths. Return an empty string when text is empty.
Input: text is a string and field_lengths is a non-empty list of positive integers.
Output: A CSV-formatted string without a trailing newline.
def parse_fixed_width(text, field_lengths):