Do not add number of attributes to data
@@ -35,16 +35,10 @@ pub fn load<F>(name: &str, mut on_load: F) where F: FnMut(String)
loader::load(name, on_l);
}
-/*fn get_words(line: String) -> Vec<&str>
-{
- let mut words: Vec<&str> = line.trim().split(' ').map(|s| s.trim()).collect();
- words.retain(|&i| i != "");
- words
-}*/
-
fn read_data<T>(lines_iter: &mut Lines<Box<BufRead>>) -> Vec<T> where T: str::FromStr
{
let mut data = Vec::new();
+ let mut no_attributes = -1;
loop
{
let line = lines_iter.next().unwrap().unwrap();
@@ -59,13 +53,22 @@ fn read_data<T>(lines_iter: &mut Lines<Box<BufRead>>) -> Vec<T> where T: str::Fr
}
for word in words {
+ if no_attributes == -1
+ {
+ match word.parse::<i32>() {
+ Ok (i) => { no_attributes = i },
+ Err(..) => {},
+ }
+ }
+ else {
match word.parse::<T>() {
- Ok (i) => data.push(i),
+ Ok (i) => {data.push(i)},
Err(..) => {},
}
}
}
}
+ }
data
}
