Commit 36022e8e authored by Olav Dagestad Eikrem's avatar Olav Dagestad Eikrem
Browse files

Write to csv updated, old used , new uses ;

parent 60165e89
......@@ -56,7 +56,8 @@ public class PatientRegister implements Initializable {
String path = fc.showOpenDialog(null).getPath();
try {
tableView.setItems(getPeopleCustom(path));
people = getPeopleCustom(path);
tableView.setItems(people);
} catch (Exception e) {
}
tableView.refresh();
......@@ -79,7 +80,7 @@ public class PatientRegister implements Initializable {
if (!(folderPath == null || folderPath.equalsIgnoreCase(""))){
try {
csvManager.addToOldFile(people, folderPath);
csvManager.writeToNewFile(people, folderPath);
}catch (Exception e){
}
......
......@@ -6,11 +6,9 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import mappe.del2.hospital.Pasient;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.util.Arrays;
import java.util.List;
public class CSVManager {
String fileName;
......@@ -106,23 +104,27 @@ public class CSVManager {
return patientList;
}
public Boolean addToOldFile(ObservableList<Pasient> patientList, String filePath) throws IOException {
String[] patients = new String[patientList.size()];
CSVWriter writer = new CSVWriter(new FileWriter(filePath));
public Boolean writeToNewFile(ObservableList<Pasient> patientList, String filePath) throws IOException {
List<String> patient;
FileWriter csvWriter = new FileWriter(filePath);
try {
for (int i = 0; i < patientList.size(); i++) {
Pasient p = patientList.get(i);
patients[i] = (p.getFirstName() + ";" + p.getLastName() + ";" + p.getGeneralPractitioner() + ";" + p.getSocialSecurityNumber());
for (Pasient p: patientList) {
patient = Arrays.asList(p.getFirstName(), p.getLastName(), p.getGeneralPractitioner(), p.getSocialSecurityNumber());
csvWriter.append(String.join(";", patient));
csvWriter.append("\n");
}
csvWriter.flush();
csvWriter.close();
writer.writeNext(patients);
}
}catch (Exception e){
e.printStackTrace();
writer.close();
csvWriter.close();
return false;
}
writer.close();
csvWriter.close();
return true;
}
......
firstName;lastNam;generalPractitioner;socialSecurityNumber
Andrø;Tanker;Maren G. Skake;29104300764
Ane;Rikke;Dr. Klø;12073004096
Anna Ellen;Flom;Matti Ompa;14109605264
Anne;Ledes;Rally McBil;28033418908
Anton;Nym;Edel Gran;7062739589
Atle;As;Pøl Asset;11084016200
Augluin;Persen;Synne Sikke;26097638798
Ben D.;Lorm;Maren G. Skake;13125334606
Ben;Sin;Matti Ompa;15085507939
Billy;Strøm;Matti Ompa;31088031566
Bob;le Dress;Dr. Klø;12073004177
David;Eo;Pøl Asset;3028013980
Die;Phat;Edel Gran;17025738276
Eilev;Fant;Rally McBil;14021720179
Ellen;Vator;Maren G. Skake;11086504873
Ellinor;Brusflasker;Edel Gran;31083135487
Else;Or;Matti Ompa;13027406496
Endre;Altnø;Dr. Klø;8040376926
Endre;Oppsett;Dr. Klø;31058633855
Endre;Passord;Dr. Klø;4074527340
Espen;Nende Historie;Edel Gran;7129349896
Gene;Sis;Edel Gran;10067048194
Gert Urtel;Due;Pøl Asset;20128832204
Gertrud I.;Hønda;Rally McBil;2094325067
Gjørde A.;Sap;Edel Gran;29104300683
Hakon;Slipp;Rally McBil;16037220292
Halvor I.;Altjegsier;Pøl Asset;11039622833
Halvor Li;Talt;Rally McBil;10084710356
Hans Mørtel;Poff;Pøl Asset;24065149393
Hans;Omvar;Pøl Asset;14021720098
Harald;Itt;Edel Gran;7032311223
Harry;Pespiller;Pøl Asset;10084710275
Hildur;Ogmoll;Pøl Asset;7129349977
Hjørdis;Elv;Edel Gran;26016214980
Huppasahn;DelFinito;Synne Sikke;30034126670
Igor;Setilbakken;Pøl Asset;26107808093
Inco;Gnito;Synne Sikke;31083135568
Inga;Lykke;Pøl Asset;10047802259
Inge;Borg;Matti Ompa;5118148993
Jack E.;Slag;Matti Ompa;14105819510
Jakob;Blyantkvesser;Edel Gran;24065149202
Jo;Ellernei;Synne Sikke;21010288069
Jøran;Drebli;Pøl Asset;26094731231
Jørn E.;Sten;Matti Ompa;2094325148
Jørn;Etan;Rally McBil;5118148802
Jørund;Erslag;Matti Ompa;27077902789
Kaja N.;Legg;Matti Ompa;14109605345
Kalle;Føtter;Edel Gran;17025738357
Kalle;Votter;Edel Gran;14101918301
Kine;Tikk;Pøl Asset;15095205027
Kjakan;Ingenting;Pøl Asset;26043041370
Kjell T.;Ring;Rally McBil;20128832395
Klara;Nett;Pøl Asset;7032311304
Kristopher;Volden;Hans Ugde;8122241611
Kurt;Isere;Edel Gran;20049920645
Kurt;Urell;Edel Gran;12074832200
Lage;Kveldsmat;Synne Sikke;29045214425
Laila;La;Pøl Asset;28033418827
Lerke;Fuglesang;Matti Ompa;15085507858
Lerke;Vinge;Matti Ompa;22080160481
Line;Tyløn;Pøl Asset;22082313099
Linn O.;Leum;Pøl Asset;25107745885
Liv;Redd;Ken Taur;13125334797
Lotte;Ri;Matti Ompa;5119339008
Ludvik;Tig;Hans Ugde;25039439940
Magne;Tisk;Matti Ompa;21092221595
Mona;Gam;Rally McBil;11039622914
Nanna;Na;Edel Gran;27082602947
Nidar;Heisen;Rally McBil;12047719176
Nidel V.;Elvefølger;Edel Gran;27082602866
Nina;Teknologi;Synne Sikke;20049920726
Nora;Toriet;Edel Gran;2089829790
Odd Even;Primtallet;Synne Sikke;30034126751
Ove;Ralt;Synne Sikke;26097638607
Per;Estrojka;Matti Ompa;13027406577
Per;Kusjon;Rally McBil;6129719409
Per;Tentlig;Matti Ompa;31088031485
Pia;No;Pøl Asset;12074832391
Ragna;Rokk;Matti Ompa;11037124550
Rigmor;Mortis;Synne Sikke;29045214506
Rikke;Sikke;Matti Ompa;13116237770
Sesam;Lukkopphagen;Edel Gran;14101918220
Siri;Kus;Maren G. Skake;15095205108
Synne;Syndpødeg;Rally McBil;26094731312
Synne T.;Sizer;Rally McBil;7088923655
Sølve;Retmetall;Matti Ompa;5119339199
Sølvi;Normalbakke;Rally McBil;11084016391
Sølvi;Smykker;Rally McBil;19040177011
Telli;Graf;Pøl Asset;25036720614
Terry;Bell;Matti Ompa;7088923736
Tom;Flaske;Dr. Klø;8040376845
Tom;Ila;Matti Ompa;22080160562
Tone;Falsk;Matti Ompa;10025823112
Tor;Ader;Rally McBil;26107808174
Tor;Sion;Rally McBil;25107745966
Tord;Envør;Rally McBil;21092221404
Tore;Genter;Matti Ompa;2102032759
Tove R.;Allefjell;Rally McBil;10025823031
Trond;Arving;Matti Ompa;16037220373
Trond;Arwin;Matti Ompa;2102032678
Trude;Arbeidsplasser;Edel Gran;10067048003
Ulrik;Smøl;Pøl Asset;12047719095
Unn;Derpari;Rally McBil;11086504954
Unni;Versell;Pøl Asset;2118126788
\ No newline at end of file
"Olav;;;12345678910"
firstName;lastNam;generalPractitioner;socialSecurityNumber
Andrø;Tanker;Maren G. Skake;29104300764
Ane;Rikke;Dr. Klø;12073004096
Anna Ellen;Flom;Matti Ompa;14109605264
Anne;Ledes;Rally McBil;28033418908
Anton;Nym;Edel Gran;7062739589
Atle;As;Pøl Asset;11084016200
Augluin;Persen;Synne Sikke;26097638798
Ben D.;Lorm;Maren G. Skake;13125334606
Ben;Sin;Matti Ompa;15085507939
Billy;Strøm;Matti Ompa;31088031566
Bob;le Dress;Dr. Klø;12073004177
David;Eo;Pøl Asset;3028013980
Die;Phat;Edel Gran;17025738276
Eilev;Fant;Rally McBil;14021720179
Ellen;Vator;Maren G. Skake;11086504873
Ellinor;Brusflasker;Edel Gran;31083135487
Else;Or;Matti Ompa;13027406496
Endre;Altnø;Dr. Klø;8040376926
Endre;Oppsett;Dr. Klø;31058633855
Endre;Passord;Dr. Klø;4074527340
Espen;Nende Historie;Edel Gran;7129349896
Gene;Sis;Edel Gran;10067048194
Gert Urtel;Due;Pøl Asset;20128832204
Gertrud I.;Hønda;Rally McBil;2094325067
Gjørde A.;Sap;Edel Gran;29104300683
Hakon;Slipp;Rally McBil;16037220292
Halvor I.;Altjegsier;Pøl Asset;11039622833
Halvor Li;Talt;Rally McBil;10084710356
Hans Mørtel;Poff;Pøl Asset;24065149393
Hans;Omvar;Pøl Asset;14021720098
Harald;Itt;Edel Gran;7032311223
Harry;Pespiller;Pøl Asset;10084710275
Hildur;Ogmoll;Pøl Asset;7129349977
Hjørdis;Elv;Edel Gran;26016214980
Huppasahn;DelFinito;Synne Sikke;30034126670
Igor;Setilbakken;Pøl Asset;26107808093
Inco;Gnito;Synne Sikke;31083135568
Inga;Lykke;Pøl Asset;10047802259
Inge;Borg;Matti Ompa;5118148993
Jack E.;Slag;Matti Ompa;14105819510
Jakob;Blyantkvesser;Edel Gran;24065149202
Jo;Ellernei;Synne Sikke;21010288069
Jøran;Drebli;Pøl Asset;26094731231
Jørn E.;Sten;Matti Ompa;2094325148
Jørn;Etan;Rally McBil;5118148802
Jørund;Erslag;Matti Ompa;27077902789
Kaja N.;Legg;Matti Ompa;14109605345
Kalle;Føtter;Edel Gran;17025738357
Kalle;Votter;Edel Gran;14101918301
Kine;Tikk;Pøl Asset;15095205027
Kjakan;Ingenting;Pøl Asset;26043041370
Kjell T.;Ring;Rally McBil;20128832395
Klara;Nett;Pøl Asset;7032311304
Kristopher;Volden;Hans Ugde;8122241611
Kurt;Isere;Edel Gran;20049920645
Kurt;Urell;Edel Gran;12074832200
Lage;Kveldsmat;Synne Sikke;29045214425
Laila;La;Pøl Asset;28033418827
Lerke;Fuglesang;Matti Ompa;15085507858
Lerke;Vinge;Matti Ompa;22080160481
Line;Tyløn;Pøl Asset;22082313099
Linn O.;Leum;Pøl Asset;25107745885
Liv;Redd;Ken Taur;13125334797
Lotte;Ri;Matti Ompa;5119339008
Ludvik;Tig;Hans Ugde;25039439940
Magne;Tisk;Matti Ompa;21092221595
Mona;Gam;Rally McBil;11039622914
Nanna;Na;Edel Gran;27082602947
Nidar;Heisen;Rally McBil;12047719176
Nidel V.;Elvefølger;Edel Gran;27082602866
Nina;Teknologi;Synne Sikke;20049920726
Nora;Toriet;Edel Gran;2089829790
Odd Even;Primtallet;Synne Sikke;30034126751
Ove;Ralt;Synne Sikke;26097638607
Per;Estrojka;Matti Ompa;13027406577
Per;Kusjon;Rally McBil;6129719409
Per;Tentlig;Matti Ompa;31088031485
Pia;No;Pøl Asset;12074832391
Ragna;Rokk;Matti Ompa;11037124550
Rigmor;Mortis;Synne Sikke;29045214506
Rikke;Sikke;Matti Ompa;13116237770
Sesam;Lukkopphagen;Edel Gran;14101918220
Siri;Kus;Maren G. Skake;15095205108
Synne;Syndpødeg;Rally McBil;26094731312
Synne T.;Sizer;Rally McBil;7088923655
Sølve;Retmetall;Matti Ompa;5119339199
Sølvi;Normalbakke;Rally McBil;11084016391
Sølvi;Smykker;Rally McBil;19040177011
Telli;Graf;Pøl Asset;25036720614
Terry;Bell;Matti Ompa;7088923736
Tom;Flaske;Dr. Klø;8040376845
Tom;Ila;Matti Ompa;22080160562
Tone;Falsk;Matti Ompa;10025823112
Tor;Ader;Rally McBil;26107808174
Tor;Sion;Rally McBil;25107745966
Tord;Envør;Rally McBil;21092221404
Tore;Genter;Matti Ompa;2102032759
Tove R.;Allefjell;Rally McBil;10025823031
Trond;Arving;Matti Ompa;16037220373
Trond;Arwin;Matti Ompa;2102032678
Trude;Arbeidsplasser;Edel Gran;10067048003
Ulrik;Smøl;Pøl Asset;12047719095
Unn;Derpari;Rally McBil;11086504954
Unni;Versell;Pøl Asset;2118126788
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment