<commit_before>package name.abuchen.portfolio.datatransfer.csv;

import java.text.MessageFormat;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import name.abuchen.portfolio.Messages;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.AmountField;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.Column;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.DateField;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.Field;
import name.abuchen.portfolio.model.Security;
import name.abuchen.portfolio.model.SecurityPrice;

/* package */class CSVSecurityPriceExtractor extends CSVExtractor
{
    private List<Field> fields;

    /* package */ CSVSecurityPriceExtractor()
    {
        fields = new ArrayList<>();
        fields.add(new DateField("date", Messages.CSVColumn_Date)); //$NON-NLS-1$
        fields.add(new AmountField("quote", Messages.CSVColumn_Quote, "Schluss", "Schlusskurs", "Close")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }

    @Override
    public String getCode()
    {
        return "investment-vehicle-price"; //$NON-NLS-1$
    }

    @Override
    public String getLabel()
    {
        return Messages.CSVDefHistoricalQuotes;
    }

    @Override
    public List<Field> getFields()
    {
        return fields;
    }

    @Override
    public List<Item> extract(int skipLines, List<String[]> rawValues, Map<String, Column> field2column,
                    List<Exception> errors)
    {
        Security dummy = new Security();

        for (String[] line : rawValues)
        {
            try
            {
                SecurityPrice p = extract(line, field2column);
                dummy.addPrice(p);
            }
            catch (ParseException e)<commit_msg>CSV import / filter negative security price<commit_after>package name.abuchen.portfolio.datatransfer.csv;

import java.text.MessageFormat;
import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import name.abuchen.portfolio.Messages;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.AmountField;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.Column;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.DateField;
import name.abuchen.portfolio.datatransfer.csv.CSVImporter.Field;
import name.abuchen.portfolio.model.Security;
import name.abuchen.portfolio.model.SecurityPrice;

/* package */class CSVSecurityPriceExtractor extends CSVExtractor
{
    private List<Field> fields;

    /* package */ CSVSecurityPriceExtractor()
    {
        fields = new ArrayList<>();
        fields.add(new DateField("date", Messages.CSVColumn_Date)); //$NON-NLS-1$
        fields.add(new AmountField("quote", Messages.CSVColumn_Quote, "Schluss", "Schlusskurs", "Close")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    }

    @Override
    public String getCode()
    {
        return "investment-vehicle-price"; //$NON-NLS-1$
    }

    @Override
    public String getLabel()
    {
        return Messages.CSVDefHistoricalQuotes;
    }

    @Override
    public List<Field> getFields()
    {
        return fields;
    }

    @Override
    public List<Item> extract(int skipLines, List<String[]> rawValues, Map<String, Column> field2column,
                    List<Exception> errors)
    {
        Security dummy = new Security();

        for (String[] line : rawValues)
        {
            try
            {
                SecurityPrice p = extract(line, field2column);
                if (p.getValue() >= 0)
                    dummy.addPrice(p);
            }
            catch (ParseException e)
{'fraction_non_alphanumeric': 0.11977641735427202, 'fraction_numerical': 0.004524886877828055, 'mean_word_length': 2.894300518134715, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5941184', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1173, 'n_words': 213}