public static void DividiFileR()
    {
        
        RegistraTempo rt = new RegistraTempo();
        rt.Start();
        try
        {
            Scanner scanner = new Scanner(System.in);
            System.out.println("Divisione file puliti da R");
            System.out.println("Sicuro?");
            String sel = "s"; //scanner.next();   
            if (!sel.equals("s"))
            {
                System.out.println("Annullato");
                return;
            }
            
            byte[] encoded = Files.readAllBytes(Paths.get(Configuration.TxtDir + "data_to_split.txt"));
            //byte[] encoded = Files.readAllBytes(Paths.get(Configuration.TxtDir + "mancanti.txt"));
            String str = Charset.defaultCharset().decode(ByteBuffer.wrap(encoded)).toString();
            String[] rows = str.split("\n");
            String lastId = "";
			PrintWriter writer = null;
            long rowCount = 0; 
            long docCount = 0; 
            long writeCount = 0; 
            double perc = 0;
            for (String row : rows)
            {
                String[] fields = row.split("\t");
                // id - type - value - term - creation - gran
                String doc_id = fields[0];
                String doc_type = fields[1];
                String doc_value = fields[2];
                String doc_term = fields[3];
                String doc_creation = fields[4];
                String doc_gran = fields[5];
                
                System.out.printf("\rRiga %d/%d", ++rowCount, rows.length);
                perc = 100 * (double)rowCount / (double)rows.length;
                System.out.printf("  %.1f%%", perc);
                
                    String filename = Configuration.HeidelCollectionRoot + "R_puliti_divisi/" + doc_id + "_" + doc_creation + ".txt";
                    writer = new PrintWriter(new FileWriter(filename, true));
                    
                if (!doc_id.equals(lastId))
                {
                    //System.out.printf("     Documents: %d", ++docCount);
                    if (!lastId.equals(""))
                    {
                        //writer.close();
                    }
                    lastId = doc_id;
                    docCount++;
                }
                writer.printf("%s\t%s\t%s\n", doc_type, doc_value, doc_gran);
                writeCount++;
                System.out.printf("   Documents: %d", docCount);
                System.out.printf("   Write: %d", writeCount);
                writer.close();
                
            }
            if (!lastId.equals(""))
            {
                //writer.close();
            }
            System.out.println();
        }
        catch (IOException ex)
        {
            System.out.println(ex);
        }
        
        rt.Stop(true);    
    }