function createCSVTransform() {
    let isFirstChunk = true;
    
    return new Transform({
        objectMode: true,
        transform(member, encoding, callback) {
            try {
                // Format the member data for CSV
                const formattedMember = formatMemberForCSV(member);
                
                // For first chunk, include the headers
                if (isFirstChunk) {
                    const csv = papaparse.unparse({
                        fields: CSV_HEADERS,
                        data: [formattedMember]
                    }, {
                        header: true,
                        escapeFormulae: true,
                        newline: '\r\n' // Explicitly set Windows-style line endings for compatibility
                    });
                    isFirstChunk = false;
                    callback(null, csv);
                } else {
                    // For subsequent chunks, don't include headers, just the data
                    const csv = papaparse.unparse({
                        fields: CSV_HEADERS,
                        data: [formattedMember]
                    }, {
                        header: false,
                        escapeFormulae: true,
                        newline: '\r\n' // Explicitly set Windows-style line endings for compatibility
                    });
                    
                    // Make sure each row starts with a newline to ensure separation between rows
                    // Ensure consistent line endings by using explicit CR+LF sequence
                    callback(null, '\r\n' + csv.replace(/^\r?\n+/, ''));
                }
            } catch (err) {
                callback(err);
            }
        }
    });
}
Create a CSV Transform stream
@returns {Transform} Transform stream that converts objects to CSV