class CSVSchemaParser implements SchemaParser {

    @Override
    public Schema parse(Request request) {
        List<Schema.SheetContent> sheetContents = new ArrayList<>();
        sheetContents.add(new Schema.SheetContent(META_KEY, new ArrayList<>()));
        try {
            final DataSetMetadata metadata = request.getMetadata();
            final Map<String, String> parameters = guess(request, metadata.getEncoding());
            metadata.getContent().setParameters(parameters);
            metadata.getContent().setNbLinesInHeader(Integer.parseInt(parameters.get(HEADER_NB_LINES_PARAMETER)));
            List<String> header = csvFormatUtils.retrieveHeader(parameters);
            if (header == null || header.isEmpty()) {
                throw new TDPException(DataSetErrorCodes.UNABLE_TO_READ_DATASET_CONTENT);
            }
            LOGGER.debug("Columns found: {}", header);
            // By default, consider all columns as Strings (to be refined by deeper analysis).
            LOGGER.debug("Setting default type for columns...");
            int i = 0;
            for (String column : header) {
                sheetContents
                        .stream()
                        .filter(sheetContent -> META_KEY.equals(sheetContent.getName()))
                        .findFirst() //
                        .get()
                        .getColumnMetadatas() //
                        .add(column().id(i++).name(column).type(Type.STRING).build());
            }
        } catch (Exception e) {
            throw new TDPException(CommonErrorCodes.UNABLE_TO_READ_CONTENT, e);
        }
        return Schema.Builder
                .parserResult() //
                .sheetContents(sheetContents) //
                .draft(false)
                .build();
    }

}