I have over 300 CSV files and I am supposed to read all of them and then perform various operation on them. First I am supposed to read the only HALF file and then, later on, I am supposed to read one-third file.
This is how the CSV files look. I am only supposed to read the avg_rss12 column and that too only half column first and then one-third later on. There are over 500 lines in each file and number of lines in each file changes for each file.
Suppose a file has 500 lines then I am supposed to read first 250(for half file) and 167 lines if I am supposed to read one-third file. The number of lines in each file is different and there are over 300 lines so I cannot manually modify each file.
# Task: bending1
# Frequency (Hz): 20
# Clock (millisecond): 250
# Duration (seconds): 120
# Columns: time avg_rss12 var_rss12 avg_rss13 var_rss13 avg_rss23 var_rss23
0 39.25 0.43 22.75 0.43 33.75 1.3
250 39.25 0.43 23 0 33 0
500 39.25 0.43 23.25 0.43 33 0
750 39.5 0.5 23 0.71 33 0
1000 39.5 0.5 24 0 33 0
1250 39.25 0.43 24 0 33 0
1500 39.25 0.43 24 0 33 0
Here is my code. For some reason, it is not reading the file at all. Also is my way the correct way or I am doing something wrong?
public static void main(String args[])
{
String path_Test = "E:\\DTW-KNN\\Dataset\\Test\\bending1\\dataset1.csv";
File dataFile = new File(path_Test);
long data_size = dataFile.length();
String[] test = null;
int count = 0;
int i;
try {
BufferedReader reader = new BufferedReader(new FileReader(dataFile));
for (i = 0; i <= data_size/2.0; i++) {
test[i] = reader.readLine();
System.out.println(test[i]);
count++;
}
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println(count);
}