CSVReader
unknown
java
4 years ago
4.7 kB
13
Indexable
pathtwo="/Users/Mariana/Documents/CSC365Fall/Project1/2020VAERSDataText.txt";
linetwo="";
FileWriter fwtwo=new FileWriter("/Users/Mariana/Documents/CSC365Fall/Project1/2020CovidVAERS.txt",true);
PrintWriter outtwo=new PrintWriter(fwtwo);
try {
BufferedReader brtwo = new BufferedReader(new FileReader(pathtwo));
linetwo = brtwo.readLine();
System.out.println("linetwo"+linetwo);
while ((linetwo = brtwo.readLine()) != null) {
int idtwo = 0;
String receiveddate = "";
String state = "";
double age= 0;
int cage_yrs = 0;
String cage_month = "";
String sex = "";
String rpt_dates = "";
String symptom_test = "";
String died = "";
String datedied = "";
String l_threat = "";
String er_visit = "";
String hospital = "";
String hospdays = "";
String x_stays = "";
String disable = "";
String recovd = "";
String vax_date = "";
String onset_date = "";
String numdays = "";
String lab_data = "";
String v_adminby = "";
String v_fundby = "";
String other_meds = "";
String cur_ill = "";
String history = "";
String prior_vax = "";
String splttype = "";
String form_vers = "";
String todays_date = "";
String birth_defect = "";
String ofc_visit = "";
String er_ed_visit = "";
String allergies = "";
// String[] valuetwo = linetwo.split(",");
String[] tokens=linetwo.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)",-1);
idtwo = Integer.parseInt(tokens[0]);
// System.out.println("id"+":"+idtwo);
receiveddate = tokens[1];
state = tokens[2];
age = Double.parseDouble(tokens[3]);
// System.out.println("age"+age);
cage_yrs = Integer.parseInt(tokens[4]);
//System.out.println("cage_trs"+":"+cage_yrs);
cage_month = tokens[5];
sex = tokens[6];
rpt_dates = tokens[7];
symptom_test = tokens[8];
// System.out.println("symptomtest"+":"+symptom_test);
died = tokens[9];
datedied = tokens[10];
l_threat = tokens[11];
er_visit = tokens[12];
hospital = tokens[13];
hospdays = tokens[14];
x_stays = tokens[15];
disable = tokens[16];
recovd = tokens[17];
vax_date = tokens[18];
onset_date = tokens[19];
numdays = tokens[20];
lab_data = tokens[21];
v_adminby = tokens[22];
v_fundby = tokens[23];
other_meds = tokens[24];
cur_ill = tokens[25];
history = tokens[26];
prior_vax = tokens[27];
splttype = tokens[28];
form_vers = tokens[29];
todays_date = tokens[30];
birth_defect = tokens[31];
ofc_visit = tokens[32];
er_ed_visit = tokens[33];
allergies = tokens[34];
currentvearsdata = new VAERSData(idtwo, receiveddate, state, age, cage_yrs, cage_month, sex, rpt_dates, symptom_test, died, datedied, l_threat, er_visit, hospital, hospdays, x_stays, disable, recovd, vax_date, onset_date, numdays, lab_data, v_adminby, v_fundby, other_meds, cur_ill, history, prior_vax, splttype, form_vers, todays_date, birth_defect, ofc_visit, er_ed_visit, allergies);
//System.out.println("tokens"+currentvearsdata.toString());
vaersdata.add(currentvearsdata);
// linetwo= brtwo.readLine(); commented this because it skipped the line
}
System.out.println(vaersdata.size());
for(VAERSData d:vaersdata){
outtwo.println(d.toString());
}
outtwo.close();
} catch (IOException e) {
e.printStackTrace();
} catch (NumberFormatException m) {
m.printStackTrace();
}Editor is loading...