pixel数据形成了304个csv文件,提取特定行列的数据整理为单独数列,为了避免手动输入很多次,用Java进行了下尝试。
import java.io.BufferedReader;
import java.io.FileReader;
public class Text {
//Method 读取824行3列的数据
public static String Test(double x,double y) throws Exception{
int n = 0;
String last="";
//文件路径
String file = "filepath"+String.valueOf(x)+"_"+String.valueOf(y)+".csv";
BufferedReader reader = new BufferedReader(new FileReader(file));
reader.readLine();
String line = null;
while((line=reader.readLine())!=null){
n += 1;
if(n == 824){
String item[] = line.split(",");
last = item[3];
}
}
reader.close();
return last;
}
//重复多个文件的操作
public static void main(String[] args) {
for (double x = 47.25; x <= 55.25;x+=0.5){
for (double y = 5.75;y <=15.25;y+=0.5){
try{
System.out.println(Test(x,y));
}catch(Exception e){
e.printStackTrace();
}
}
}
}
}