繁体   English   中英

从另存为CSV文件的Excel电子表格中读取特定行

[英]Reading in specific lines from an Excel spreadsheet saved as CSV file

我有一个名为TemperatureProfile的类,其对象具有两个属性:

  • 月份名称数组(类型String[] ),以及
  • 和温度数组(类型double[] )。

现在,必须从另存为CSV文件的Excel电子表格中读取这两个属性的数据。 月份名称在第一列中,温度在第二列中。

我无法从这些单独的列中读取数据。

public class TemperatureProfile {
    private double[] temperatures;
    private String[] monthNames;
    public TemperatureProfile(String filename){
      ///Read data here, and store result in monthNames and temperatures respectively.
    }
}
    public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new FileReader(new File("F:\\test.csv")));
    String line = null;
    while ((line = reader.readLine())!=null){
        String[] splitrow = line.split(";");
        System.out.println(splitrow[0] + " - "+splitrow[1]);
    }
    reader.close();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM