Re-adding guessValueType feature which was mistakenly removed in r797.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@873 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
b4c4c4308c
commit
6409f1531c
@ -5,6 +5,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Reader;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
@ -112,7 +113,8 @@ public class TsvCsvImporter implements Importer {
|
||||
for(String s : cells){
|
||||
s = s.trim();
|
||||
if (ExpressionUtils.isNonBlankData(s)) {
|
||||
row.cells.add(new Cell(s, null));
|
||||
Serializable value = guessValueType ? ImporterUtilities.parseCellValue(s) : s;
|
||||
row.cells.add(new Cell(value, null));
|
||||
}else{
|
||||
row.cells.add(null);
|
||||
}
|
||||
|
@ -126,6 +126,28 @@ public class TsvCsvImporterTests {
|
||||
Assert.assertEquals(project.rows.get(0).cells.get(2).value, "data3");
|
||||
}
|
||||
|
||||
@Test(dataProvider = "CSV-or-null")
|
||||
public void readSimpleData_CSV_1Header_1Row_GuessValues(String sep){
|
||||
String input = "col1,col2,col3\n" +
|
||||
"data1,234,data3";
|
||||
LineNumberReader lnReader = new LineNumberReader(new StringReader(input));
|
||||
try {
|
||||
SUT.read(lnReader, project, sep, -1, 0, 0, 1, true, true);
|
||||
} catch (IOException e) {
|
||||
Assert.fail();
|
||||
}
|
||||
Assert.assertEquals(project.columnModel.columns.size(), 3);
|
||||
Assert.assertEquals(project.columnModel.columns.get(0).getName(), "col1");
|
||||
Assert.assertEquals(project.columnModel.columns.get(1).getName(), "col2");
|
||||
Assert.assertEquals(project.columnModel.columns.get(2).getName(), "col3");
|
||||
Assert.assertEquals(project.rows.size(), 1);
|
||||
Assert.assertEquals(project.rows.get(0).cells.size(), 3);
|
||||
Assert.assertEquals(project.rows.get(0).cells.get(0).value, "data1");
|
||||
Assert.assertTrue(project.rows.get(0).cells.get(1).value instanceof Long);
|
||||
Assert.assertEquals(project.rows.get(0).cells.get(1).value, Long.parseLong("234"));
|
||||
Assert.assertEquals(project.rows.get(0).cells.get(2).value, "data3");
|
||||
}
|
||||
|
||||
@Test(dataProvider = "CSV-or-null")
|
||||
public void readSimpleData_0Header_1Row(String sep){
|
||||
String input = "data1,data2,data3";
|
||||
|
Loading…
Reference in New Issue
Block a user