/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csvtransform;

import java.io.*;


/**
 *
 * @author Brais
 */
public class csvtransform {

    /**
     * @param args the command line arguments
     */
    
    public static void writeContent(String nameFile, String newLine) throws IOException
    {
      File newFile = new File ("temperaturasFormato/"+nameFile);
      FileWriter w = new FileWriter(newFile,true);
      BufferedWriter bw = new BufferedWriter(w);
      //New file creation if it does not exist
      if(!newFile.exists())
        if(!newFile.createNewFile())
              System.out.println("Error! Problems to create the file"+nameFile);
      
      //Write in the new file
      bw.write(newLine+"\n");        
      bw.close();  //Close buffer
    }
    
    public static void readContent(String nameFile) throws FileNotFoundException, IOException 
    {
          String line,newLine;
          FileReader file = new FileReader("temperaturas/"+nameFile);
          BufferedReader buffer = new BufferedReader(file);
          while((line = buffer.readLine())!=null) 
          {
              
              newLine=nameFile.substring(0,4)+","+nameFile.substring(4,6)+","+line.replace(" ", ",");
              writeContent(nameFile,newLine);
              //System.out.println(newLine);//System to see printing
          }
          buffer.close();//Close buffer
    }
    
    
    public static void runningFiles() throws IOException
    {//Loop to go over all of files, since 1854 to 2014, 7º month
      int i=0,j=0;
       
      //Loop of years
       for(i=1854;i<2015;i++)
           for(j=1;j<=12;j++)//Loop of months
               if(j<10)//Checking of month number
                   if(i==2014 && j==8)//if statement to finalize the program
                       System.exit(0);
                   else
                    readContent(i+"0"+j+"15"); 
                else
                 readContent(i+""+j+"15"); 
               
    }
    


    
    public static void main(String[] args) throws IOException 
    {
        // TODO code application logic here
        runningFiles();
    }
}

@@ -256,24 +256,79 @@
     */%0A    %0A
+    //Function to put the new content in the new files%0A
     public s
@@ -463,32 +463,39 @@
 rmato/%22+nameFile
++%22.csv%22
 );%0A      FileWri
@@ -890,24 +890,72 @@
 %0A    %7D%0A    %0A
+    //Function to read the content of each line%0A
     public s
@@ -1266,28 +1266,16 @@
        %7B
-%0A           
    %0A    
@@ -1296,64 +1296,8 @@
 ine=
-nameFile.substring(0,4)+%22,%22+nameFile.substring(4,6)+%22,%22+
 line
@@ -1351,16 +1351,32 @@
 nameFile
+.substring(0, 6)
 ,newLine
@@ -1510,24 +1510,54 @@
  %7D%0A    %0A    
+//Function to see all of files
 %0A    public 
@@ -2100,24 +2100,8 @@
 ); %0A
-               %0A
     
@@ -2107,18 +2107,16 @@
  %7D%0A    %0A
-%0A%0A
     %0A   
@@ -2195,40 +2195,36 @@
   //
- TODO code application logic her
+Process to adequate csv styl
 e%0A  
@@ -2244,16 +2244,24 @@
 Files();
+        
 %0A    %7D%0A%7D

Version 5.0, New changes to adequate the format