Rapid miner:CSV,实数用逗号代替点

Rapid miner:CSV,实数用逗号代替点,csv,floating-point,machine-learning,data-mining,rapidminer,Csv,Floating Point,Machine Learning,Data Mining,Rapidminer,我在使用RapidMiner导入CSV文件时遇到问题。 浮点值是用逗号写入的,而不是整数值和十进制数值之间的分隔点 有人知道如何正确导入以这种方式格式化的值吗 样本数据: 体重指数;1.0;1.1.1.蓝色-0,138812155;0,520378909;5.0;50;107;0;9;0;其他;好,;2011 体重指数;1.0;1.1.1.粉红色-0,624654696;;8.0;73;120;1.3.0,882638889;其他;好,;2011 Rapid miner实际上将其解释为“多项

我在使用RapidMiner导入CSV文件时遇到问题。 浮点值是用逗号写入的,而不是整数值和十进制数值之间的分隔点

有人知道如何正确导入以这种方式格式化的值吗

样本数据:


体重指数;1.0;1.1.1.蓝色-0,138812155;0,520378909;5.0;50;107;0;9;0;其他;好,;2011
体重指数;1.0;1.1.1.粉红色-0,624654696;;8.0;73;120;1.3.0,882638889;其他;好,;2011

Rapid miner实际上将其解释为“多项式”。将其强制为“real”只会导致对“0”值的正确解释


谢谢

请使用分号作为分隔符。您可以使用
java.util.Scanner
读取每一行
String.split()
在分号上拆分。当您获得带有逗号的标记时,可以使用
String.replace()
将逗号更改为十进制。然后可以使用
Float.parseFloat()


希望这能回答您的问题。

使用分号作为分隔符。您可以使用
java.util.Scanner
读取每一行
String.split()
在分号上拆分。当您获得带有逗号的标记时,可以使用
String.replace()
将逗号更改为十进制。然后可以使用
Float.parseFloat()

public static void main(String args){
    BufferedReader br = new BufferedReader(new FileReader("c:\\path\\semicolons and numbers and commas.csv"));
    try {
        for(String line; (line=br.readLine()) != null);) {
            //Variable line now has a single line from the file. This code will execute for each line.
            String array = line.split(";");// Split on the semicolon. Beware of changing this. This uses regex which means that some characters mean something like . means anything, not just dots.
            double firstDouble = Double.parseDouble(array[7].replace(',','.')); // Get field 7 (the eighth field) and turn it into a double (high precision floating point). Replace , with . so it will not make an error
            System.err.println("Have a number " + firstDouble);
            System.err.println("Can play with it " + (firstDouble * 2.0));
        }
    }finally{
        br.close(); // Free resources (and unlock file on Windows).
    }
}

希望这能回答您的问题。

这似乎是一个非常古老的请求。不确定这是否会帮助你,但这可能会帮助其他有类似情况的人

public static void main(String args){
    BufferedReader br = new BufferedReader(new FileReader("c:\\path\\semicolons and numbers and commas.csv"));
    try {
        for(String line; (line=br.readLine()) != null);) {
            //Variable line now has a single line from the file. This code will execute for each line.
            String array = line.split(";");// Split on the semicolon. Beware of changing this. This uses regex which means that some characters mean something like . means anything, not just dots.
            double firstDouble = Double.parseDouble(array[7].replace(',','.')); // Get field 7 (the eighth field) and turn it into a double (high precision floating point). Replace , with . so it will not make an error
            System.err.println("Have a number " + firstDouble);
            System.err.println("Can play with it " + (firstDouble * 2.0));
        }
    }finally{
        br.close(); // Free resources (and unlock file on Windows).
    }
}
步骤1:在“读取CSV”操作符的“导入配置向导”下,确保选择“分号”作为分隔符

步骤2:使用“猜测类型”操作符。属性过滤器类型->子集,选择属性->选择属性8、9和16(根据上面的示例),将“小数点字符”更改为“,”,您应该都设置好了


希望这能帮助(某人!)

这似乎是一个非常古老的请求。不确定这是否会帮助你,但这可能会帮助其他有类似情况的人

步骤1:在“读取CSV”操作符的“导入配置向导”下,确保选择“分号”作为分隔符

步骤2:使用“猜测类型”操作符。属性过滤器类型->子集,选择属性->选择属性8、9和16(根据上面的示例),将“小数点字符”更改为“,”,您应该都设置好了


希望这对(某人!)有所帮助。

你能给我们看几行CSV,这样我们就可以测试我们可能提出的解决方案,而不会在以后发现它们是错误的吗?你能给我们看几行CSV,这样我们就可以测试我们可能提出的解决方案,而不会在以后发现它们是错误的吗?谢谢你的回答。不幸的是,我刚刚开始学习RapidMiner,只使用GUI。有没有简单的方法可以用GUI来实现它?对不起。我对RapidMiner不熟悉。祝你好运。谢谢你的回答。不幸的是,我刚刚开始学习RapidMiner,只使用GUI。有没有简单的方法可以用GUI来实现它?对不起。我对RapidMiner不熟悉。祝你好运