簡體   English   中英

我正在嘗試讀取CSV文件並將其在excel中顯示為CSV文件

[英]I'm trying to read a CSV file and display it in excel as a csv file

***我有錯誤指出:

錯誤:在Main類中未找到Main方法,請將main方法定義為:
public static void main(String [] args)我已經解決了上一個問題,但現在遇到了此錯誤:C:\\ Program Files \\ Java \\ jre1.8.0_60 \\ bin \\ javaw.exe(2015年11月8日,7: 41:12 PM)
嘗試運行此代碼時:***包filtermovingaverage;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

public class Main {
    //public static void main(String[] args){


    private static double freqS = 100;
    static ArrayList<Double> sec = null; 
    private static double[] pressure = new double[20481];

    void func() throws IOException
    {
        BufferedReader read = new BufferedReader(new FileReader(new File("C:\\Users\\KwakuK\\Downloads\\smith2.csv")));        
        String currentLine = new String();
        currentLine = read.readLine();
        int i = 0;
        //make some computation
        while((currentLine = read.readLine()) != null)
        {
            String[] numbers = currentLine.split(","); // split the string into sub strings
            if(numbers.length >= 3)
            {
                    System.out.println("currentLine: " + " " + currentLine);

                pressure[i++] = Double.parseDouble(numbers[2]); // when you do the 2, it's the third column which is the pressure
            }
        }
    }

    public static void setupFirstPlot() throws FileNotFoundException{
        sec = new ArrayList<Double>();
        double ws = 1/freqS;
        double n = (pressure.length)*ws;

        for(double i = 0; i < n; i = i + ws){ 
            sec.add(i);
        }
        PrintWriter pw = new PrintWriter(new File("plot13.csv"));
        for(int i = 0; i < pressure.length; i++){
            pw.write(sec.get(i)+","+pressure[i]+"\n");
        }
        pw.close();
    }

    public static void main(String[] args) throws FileNotFoundException{
        setupFirstPlot();
        System.out.println();
    }
}

嘗試添加package filtermovingaverage; 此Java文件的頂部。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM