def export_csv():
    folder = 'csv'
    name = get_dataset_filename()
    
    # Create a folder in the temp directory if it does not exist
    temp_working_folder = os.path.join(temp_workspace,folder)
    create_folder(temp_working_folder, True)
    
    # Export the csv to the folder
    source = staging_feature_class
    destination = os.path.join(temp_working_folder,name + '.csv')

    # Export the csv
    logger.debug('Exporting to csv from "' + source + '" to "' + destination + '"')

    rows = arcpy.SearchCursor(source)
    
    # Open the destination CSV file
    csv_file = open(destination, 'wb')
    csv_writer = csv.writer(csv_file)
        
    # Get the field names
    fieldnames = [f.name for f in arcpy.ListFields(source)]
    
    # Exclude the OBJECTID field
    if 'OBJECTID' in fieldnames:
        fieldnames.remove('OBJECTID')
            
    # Exclude the shape field for now (TODO: publish as geojson in the future)
    if 'SHAPE' in fieldnames:
        fieldnames.remove('SHAPE')
    
    # Write the header row
    csv_writer.writerow(fieldnames)
    
    # Write the values to CSV.
    error_report = ''
    error_count = 0
    for row in rows:
        values = []
        for field in fieldnames:
                values.append(row.getValue(field))
        try:            
            csv_writer.writerow(values)
        except:
            # Catch any exceptions and consolidate a single error report.
            error_count += 1
            error_report = '{0}\n{1}'.format(error_report, values)
            if logger:
                logger.debug('Error publishing record to CSV for dataset {0}. {1} {2} {3}'.format(args.dataset_name,sys.exc_info()[1], sys.exc_info()[0], values))
    
    # Close the CSV file
    csv_file.close()

    # Log an exception for all records that have failed on this dataset    
    if error_count > 0:
        sys.exc_clear()
        logger.exception('Error publishing CSV for dataset {0}. The following records prevented the CSV from publish correctly. Check for invalid characters: {1}'.format(args.dataset_name, error_report))
    else:
        # Publish the csv to the download folder
        publish_file(temp_working_folder, name + '.csv','csv')
Passing C{conditionalExtensions} as a list of L{ConditionalExtension}
dataset/ETHPy150Open opencolorado/OpenColorado-Tools-and-Utilities/Scripts/ArcGIS/10.0/Python/PublishOpenDataset.py/export_csv--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/python/test/test_dist.py/SetupTest.test_conditionalExtensions