Skip to content
Snippets Groups Projects
Commit 75839812 authored by Blersch Lara's avatar Blersch Lara
Browse files

fixed bug in method getMeasurementFromString

parent bd3ad775
No related branches found
No related tags found
No related merge requests found
...@@ -64,7 +64,8 @@ public class CSVParser { ...@@ -64,7 +64,8 @@ public class CSVParser {
final List<Double> nutrition = new ArrayList<>(); final List<Double> nutrition = new ArrayList<>();
for (int i = 1; i < idx.length; i++) { for (int i = 1; i < idx.length; i++) {
String element = splitLine.get(idx[i]).split(" ")[0]; //String element = splitLine.get(idx[i]).split(" ")[0];
String element = splitLine.get(idx[i]);
double quantity = parseNumberFromString(element); double quantity = parseNumberFromString(element);
if (getMeasurementFromString(element).equals("mg")) { if (getMeasurementFromString(element).equals("mg")) {
quantity = quantity /1000; quantity = quantity /1000;
...@@ -143,7 +144,7 @@ public class CSVParser { ...@@ -143,7 +144,7 @@ public class CSVParser {
StringBuilder unit = new StringBuilder(); StringBuilder unit = new StringBuilder();
for (int i = 0; i < candidate.length(); i++) { for (int i = 0; i < candidate.length(); i++) {
char c = candidate.charAt(i); char c = candidate.charAt(i);
if (!Character.isDigit(c) && !(c == ' ')) { if (!Character.isDigit(c) && !(c == ' ') && !(c == '.')) {
unit.append(c); unit.append(c);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment