2017-10-04 4 views
-4

あなたは私に助けてくれますか?私はdataminingにいくつかのデータを前処理する簡単なプログラムが必要ですが、これをjavaでやってみようとしていますが、あなたはそれを修正するのを助ける?ありがとう。ファイルを読み取っているうちに配列外の配列が外にある

タスクは本当に簡単です。ただ2つのファイルを読み、必要な情報を3番目に書き込んでください。

 try { 
      while ((linhapessoa = pessoain.readLine())!= null) 
      { 
       String[] splitlinhapessoa = linhapessoa.split(","); 
       String pessoaId = splitlinhapessoa[1] + splitlinhapessoa[2] + splitlinhapessoa[3] + splitlinhapessoa[4] 
       + splitlinhapessoa[23]; 
       String domclId = splitlinhapessoa[1] + splitlinhapessoa[2] + splitlinhapessoa[3] + splitlinhapessoa[4]; 

       while ((linhaconsumo = consumoin.readLine())!= null) 
       { 
       String[] splitlinhaconsumo = linhaconsumo.split(","); 
       String con_pessoaId = splitlinhaconsumo[1] + splitlinhaconsumo[2] + splitlinhaconsumo[3] + 
       splitlinhaconsumo[4] + splitlinhaconsumo[21] ; 
       String con_domclId = splitlinhaconsumo[1] + splitlinhaconsumo[2] + splitlinhaconsumo[3] + splitlinhaconsumo[4]; 




       if (pessoaId.equals(con_pessoaId)) 
       { 
        if (((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "801"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1101"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1301"))| 
         ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "2401"))| 
         ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "2402"))) 
         {cons_celular = "1"; val_cons_celular = splitlinhaconsumo[11];} 

        if (((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "801"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "901"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1101"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1401"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "401"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "501"))) 
         {cons_telfixo = "1"; val_cons_telfixo = splitlinhaconsumo[11];} 

        if ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "1101")) 
        { 
        cons_shows = "1"; val_cons_shows = splitlinhaconsumo[11]; 
        } 

        if (((splitlinhaconsumo[9] == "13") && (splitlinhaconsumo[10] == "1701"))| 
         ((splitlinhaconsumo[9] == "15") && (splitlinhaconsumo[10] == "2701"))| 
         ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "5701"))| 
         ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "2601"))| 
         ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "901")))      
         {cons_dvd = "1"; val_cons_dvd = splitlinhaconsumo[11]; } 

        if (((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "502"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "503"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "504"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "505"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "506"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "801"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "901"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1001"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1301"))| 
         ((splitlinhaconsumo[9] == "6") && (splitlinhaconsumo[10] == "1401")))      
         {cons_internet = "1"; val_cons_internet = splitlinhaconsumo[11]; } 

        if ((splitlinhaconsumo[9] == "28") && (splitlinhaconsumo[10] == "101")) 
        {cons_cinema = "1"; val_cons_cinema = splitlinhaconsumo[11]; } 




        String linhasaida = linhapessoa + "," + cons_celular + "," + val_cons_celular + "," + cons_telfixo+ "," + val_cons_telfixo + 
        "," + cons_shows + "," + val_cons_shows + "," + cons_dvd + "," + val_cons_dvd + "," + cons_internet + "," + val_cons_internet 
          + "," + cons_cinema + "," + val_cons_cinema; 

        processado.write(linhasaida); 

       } 
+2

完全なエラーメッセージとスタックトレースを貼り付けることはできますか?小さなコードサンプルで問題を再現できますか? –

+3

文字列を '=='と比較しないでください。私たちに[mcve]を見せてください。巨大な壁のコードを通過するのは面倒です。 – Gendarme

+0

'ファイルを読み込んでいる間に'はそれとは関係ありません。関連性を保つ。 – EJP

答えて

0

Javaの配列(ほとんどの言語ではありますが、すべての言語ではありません)は0のインデックスが付けられています。

最初の列は1ではなく0です。

関連する問題