'Reads the samples csv file and imports all the samples.  The csv file must be in the following format.  The [:FieldValue]
is optional, the form field will contain the value after the \':\' if included.
SampleName,DataLibraryName,DataLibraryFolderName,HistoryName,WorkflowName,Field1Name:Field1Value,Field2Name:Field2Value...'

def __import_samples(self, trans, cntrller, request, displayable_sample_widgets, libraries, workflows, **kwd):

    params = util.Params(kwd)
    file_obj = params.get('file_data', '')
    try:
        reader = csv.reader(file_obj.file)
        for row in reader:
            library_id = None
            library = None
            folder_id = None
            folder = None
            history_id = None
            history = None
            workflow_id = None
            workflow = None
            library = trans.sa_session.query(trans.model.Library).filter(and_((trans.model.Library.table.c.name == row[1]), (trans.model.Library.table.c.deleted == false()))).first()
            if library:
                for folder in trans.sa_session.query(trans.model.LibraryFolder).filter(and_((trans.model.LibraryFolder.table.c.name == row[2]), (trans.model.LibraryFolder.table.c.deleted == false()))):
                    if (folder.parent_library == library):
                        break
                if folder:
                    library_id = trans.security.encode_id(library.id)
                    folder_id = trans.security.encode_id(folder.id)
            (library_select_field, folder_select_field) = self.__build_library_and_folder_select_fields(trans, request.user, len(displayable_sample_widgets), libraries, None, library_id, folder_id, **kwd)
            history = trans.sa_session.query(trans.model.History).filter(and_((trans.model.History.table.c.name == row[3]), (trans.model.History.table.c.deleted == false()), (trans.model.History.user_id == trans.user.id))).first()
            if history:
                history_id = trans.security.encode_id(history.id)
            else:
                history_id = 'none'
            history_select_field = self.__build_history_select_field(trans=trans, user=request.user, sample_index=len(displayable_sample_widgets), history_id=history_id)
            workflow = trans.sa_session.query(trans.model.StoredWorkflow).filter(and_((trans.model.StoredWorkflow.table.c.name == row[4]), (trans.model.StoredWorkflow.table.c.deleted == false()), (trans.model.StoredWorkflow.user_id == trans.user.id))).first()
            if workflow:
                workflow_id = trans.security.encode_id(workflow.id)
            else:
                workflow_id = 'none'
            workflow_select_field = self.__build_workflow_select_field(trans=trans, user=request.user, request=request, sample_index=len(displayable_sample_widgets), workflow_id=workflow_id, history_id=history_id)
            field_values = {}
            field_names = row[5:]
            for field_name in field_names:
                if (field_name.find(':') >= 0):
                    field_list = field_name.split(':')
                    field_name = field_list[0]
                    field_value = field_list[1]
                else:
                    field_value = ''
                field_values[field_name] = field_value
            displayable_sample_widgets.append(dict(id=None, name=row[0], bar_code='', library=library, library_id=library_id, library_select_field=library_select_field, folder=folder, folder_id=folder_id, folder_select_field=folder_select_field, history=history, history_id=history_id, history_select_field=history_select_field, workflow=workflow, workflow_id=workflow_id, workflow_select_field=workflow_select_field, field_values=field_values))
    except Exception as e:
        if (str(e) == "'unicode'    object    has    no    attribute    'file'"):
            message = 'Select    a    file'
        else:
            message = ('Error    attempting    to    create    samples    from    selected    file:    %s.' % str(e))
            message += '        Make    sure    the    selected    csv    file    uses    the    format:    SampleName,DataLibrary,DataLibraryFolder,FieldValue1,FieldValue2...'
        return trans.response.send_redirect(web.url_for(controller='requests_common', action='add_sample', cntrller=cntrller, request_id=trans.security.encode_id(request.id), add_sample_button='Add    sample', status='error', message=message))
    request_widgets = self.__get_request_widgets(trans, request.id)
    sample_copy_select_field = self.__build_copy_sample_select_field(trans, displayable_sample_widgets)
    return trans.fill_template('/requests/common/add_samples.mako', cntrller=cntrller, request=request, request_widgets=request_widgets, displayable_sample_widgets=displayable_sample_widgets, sample_copy_select_field=sample_copy_select_field)
