Skip any row that has all empty cells.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@8 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-01-27 02:20:13 +00:00
parent e5bba41062
commit 73ecc8f5d2

View File

@ -74,20 +74,18 @@ public class CreateProjectFromUploadCommand extends Command {
} else {
Row row = new Row(cellCount);
if (sep.charAt(0) == ',') {
parseCSVIntoRow(row, line);
} else {
parseTSVIntoRow(row, line);
if ((sep.charAt(0) == ',') ? parseCSVIntoRow(row, line) : parseTSVIntoRow(row, line)) {
project.rows.add(row);
}
project.rows.add(row);
}
}
redirect(response, "/project.html?project=" + project.id);
}
static protected void parseTSVIntoRow(Row row, String line) {
static protected boolean parseTSVIntoRow(Row row, String line) {
boolean hasData = false;
String[] cells = line.split("\t");
for (int c = 0; c < cells.length; c++) {
String text = cells[c];
@ -96,10 +94,17 @@ public class CreateProjectFromUploadCommand extends Command {
cell.value = parseCellValue(text);
row.cells.add(cell);
if (text.length() > 0) {
hasData = true;
}
}
return hasData;
}
static protected void parseCSVIntoRow(Row row, String line) {
static protected boolean parseCSVIntoRow(Row row, String line) {
boolean hasData = false;
int start = 0;
while (start < line.length()) {
String text = null;
@ -128,7 +133,13 @@ public class CreateProjectFromUploadCommand extends Command {
cell.value = parseCellValue(text);
row.cells.add(cell);
if (text.length() > 0) {
hasData = true;
}
}
return hasData;
}
static public Object parseCellValue(String text) {