1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
//ma classe main
public void CaptureColonne() throws IOException {
CSVReader reader = new CSVReader(new FileReader(fichier), ';');
String [] nextLine;
String contenant = "";
List<Enregistrement> listeAvecDoublon = new ArrayList();
bw = new BufferedWriter(new FileWriter(cheminTF+"test.dbf", false));
while ((nextLine = reader.readNext()) != null)
{
// Afficher les 5 bonnes colonnes
//System.out.println ("1 : "+nextLine[0] + " 2 : "+nextLine[1]+" 3 : "+nextLine[2]+" 6 : "+nextLine[5]+
// " 7 : "+nextLine[6]);
contenant += nextLine[0] + ";"+nextLine[1]+";"+nextLine[2]+";"+nextLine[5]+
";"+nextLine[6]+";\n";
Enregistrement Eleve = new Enregistrement(nextLine[0],nextLine[1],nextLine[2],nextLine[5],nextLine[6]);
System.out.println("Eleve créé !");
listeAvecDoublon.add(Eleve);
}
reader.close();
bw.write(contenant);
bw.close();
JOptionPane.showMessageDialog(null, "Génération terminée.","Terminé !", JOptionPane.INFORMATION_MESSAGE);
Map<String,Map<String,List<Enregistrement>>> listeStructure = new HashMap<String,Map<String,List<Enregistrement>>>();
for(Enregistrement ligne : listeAvecDoublon){
if(listeStructure.get(ligne.getNom())== null){
Map<String,List<Enregistrement>> prenomStructure = new HashMap<String,List<Enregistrement>>();
List<Enregistrement> listeDoublon = new ArrayList<Enregistrement>();
listeDoublon.add(ligne);
prenomStructure .put(ligne.getPrenom() ,listeDoublon);
listeStructure.put(ligne.getNom(),prenomStructure );
}else {
listeStructure .get(ligne.getNom()).get(ligne.getPrenom()).add(ligne);
System.out.println(ligne.getNom()+" "+ligne.getPrenom()+" est en doublon");
}}
} |
Partager