Fixed Issue 477 in google-refine: Implement or remove the line separator option.
Also, fixed displaying bug in the fixed-width parser UI: previously, tab characters forced columns to be wider. git-svn-id: http://google-refine.googlecode.com/svn/trunk@2364 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
a35b9f53f7
commit
5aec75696d
@ -44,7 +44,6 @@ public class FixedWidthImporter extends TabularImportingParserBase {
|
||||
}
|
||||
}
|
||||
|
||||
JSONUtilities.safePut(options, "lineSeparator", "\\n");
|
||||
JSONUtilities.safePut(options, "headerLines", 0);
|
||||
JSONUtilities.safePut(options, "columnWidths", columnWidths);
|
||||
JSONUtilities.safePut(options, "guessCellValueTypes", true);
|
||||
@ -63,8 +62,6 @@ public class FixedWidthImporter extends TabularImportingParserBase {
|
||||
JSONObject options,
|
||||
List<Exception> exceptions
|
||||
) {
|
||||
// String lineSeparator = JSONUtilities.getString(options, "lineSeparator", "\\n");
|
||||
// lineSeparator = StringEscapeUtils.unescapeJava(lineSeparator);
|
||||
final int[] columnWidths = JSONUtilities.getIntArray(options, "columnWidths");
|
||||
|
||||
List<Object> retrievedColumnNames = null;
|
||||
|
@ -27,7 +27,6 @@ public class LineBasedImporter extends TabularImportingParserBase {
|
||||
ImportingJob job, List<JSONObject> fileRecords, String format) {
|
||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||
|
||||
JSONUtilities.safePut(options, "lineSeparator", "\\n");
|
||||
JSONUtilities.safePut(options, "linesPerRow", 1);
|
||||
JSONUtilities.safePut(options, "headerLines", 0);
|
||||
JSONUtilities.safePut(options, "guessCellValueTypes", true);
|
||||
|
@ -69,8 +69,6 @@ public class SeparatorBasedImporter extends TabularImportingParserBase {
|
||||
List<JSONObject> fileRecords, String format) {
|
||||
JSONObject options = super.createParserUIInitializationData(job, fileRecords, format);
|
||||
|
||||
JSONUtilities.safePut(options, "lineSeparator", "\\n");
|
||||
|
||||
String separator = guessSeparator(job, fileRecords);
|
||||
JSONUtilities.safePut(options, "separator", separator != null ? separator : "\\t");
|
||||
|
||||
@ -91,8 +89,6 @@ public class SeparatorBasedImporter extends TabularImportingParserBase {
|
||||
JSONObject options,
|
||||
List<Exception> exceptions
|
||||
) {
|
||||
// String lineSeparator = JSONUtilities.getString(options, "lineSeparator", "\\n");
|
||||
// lineSeparator = StringEscapeUtils.unescapeJava(lineSeparator);
|
||||
String sep = JSONUtilities.getString(options, "separator", "\\t");
|
||||
if (sep == null || "".equals(sep)) {
|
||||
sep = "\\t";
|
||||
|
@ -6,7 +6,7 @@
|
||||
<td><input bind="encodingInput"></input></td>
|
||||
</tr>
|
||||
</table></div></td>
|
||||
<td colspan="2"><div class="grid-layout layout-tighter layout-full"><table>
|
||||
<td><div class="grid-layout layout-tighter layout-full"><table>
|
||||
<tr>
|
||||
<td style="text-align: right;"> </td>
|
||||
<td width="1%"><button class="button" bind="previewButton">Update Preview</button></td>
|
||||
@ -14,22 +14,12 @@
|
||||
</table></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"><div class="grid-layout layout-tightest"><table>
|
||||
<td colspan="2"><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td>Column widths:</td><td><input style="width: 40em;" bind="columnWidthsInput" /></td><td>comma separated numbers</td></tr>
|
||||
<tr><td>Column names:</td><td><input style="width: 40em;" bind="columnNamesInput" /></td><td>optional, comma separated</td></tr>
|
||||
</table></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td colspan="2">Rows are separated by</td></tr>
|
||||
<tr><td width="1%"><input type="radio" name="row-separator" value="new-line" id="$row-separator-new-line" /></td>
|
||||
<td><label for="$row-separator-new-line">new line characters \n</label></td></tr>
|
||||
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" id="$row-separator-custom" /></td>
|
||||
<td><label for="$row-separator-custom">custom</label>
|
||||
<input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
|
||||
<tr><td colspan="2">Escape special characters with \</td></tr>
|
||||
</table></div></td>
|
||||
|
||||
<td><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
|
||||
<td><label for="$ignore">Ignore first</label></td>
|
||||
|
@ -72,12 +72,6 @@ Refine.FixedWidthParserUI.prototype.getOptions = function() {
|
||||
options.columnNames = columnNames;
|
||||
}
|
||||
|
||||
if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") {
|
||||
options.lineSeparator = "\\n";
|
||||
} else {
|
||||
options.lineSeparator = this._optionContainerElmts.rowSeparatorInput[0].value;
|
||||
}
|
||||
|
||||
var parseIntDefault = function(s, def) {
|
||||
try {
|
||||
var n = parseInt(s,10);
|
||||
@ -140,11 +134,6 @@ Refine.FixedWidthParserUI.prototype._initialize = function() {
|
||||
this._optionContainerElmts.columnNamesInput[0].value = this._config.columnNames.join(',');
|
||||
}
|
||||
|
||||
var rowSeparatorValue = (this._config.lineSeparator == "\\n") ? 'new-line' : 'custom';
|
||||
this._optionContainer.find(
|
||||
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
|
||||
this._optionContainerElmts.rowSeparatorInput[0].value = this._config.lineSeparator;
|
||||
|
||||
if (this._config.ignoreLines > 0) {
|
||||
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
|
||||
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
|
||||
@ -326,7 +315,7 @@ Refine.FixedWidthPreviewTable.prototype._render = function() {
|
||||
.attr("target", "_blank")
|
||||
.appendTo(divContent);
|
||||
} else {
|
||||
$('<span>').text(cell.v).appendTo(divContent);
|
||||
$('<span>').text(cell.v.replace(/\s/g, ' ')).appendTo(divContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
<td><input bind="encodingInput"></input></td>
|
||||
</tr>
|
||||
</table></div></td>
|
||||
<td colspan="2"><div class="grid-layout layout-tighter layout-full"><table>
|
||||
<td><div class="grid-layout layout-tighter layout-full"><table>
|
||||
<tr>
|
||||
<td style="text-align: right;"> </td>
|
||||
<td width="1%"><button class="button" bind="previewButton">Update Preview</button></td>
|
||||
@ -19,16 +19,6 @@
|
||||
lines into one row
|
||||
</td></tr>
|
||||
|
||||
<tr><td colspan="2">Lines are separated by</td></tr>
|
||||
<tr><td width="1%"><input type="radio" name="row-separator" value="new-line" id="$row-separator-new-line" /></td>
|
||||
<td><label for="$row-separator-new-line">new line characters \n</label></td></tr>
|
||||
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" id="$row-separator-custom" /></td>
|
||||
<td><label for="$row-separator-custom">custom</label>
|
||||
<input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
|
||||
<tr><td colspan="2">Escape special characters with \</td></tr>
|
||||
</table></div></td>
|
||||
|
||||
<td><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td width="1%"><input type="checkbox" bind="storeBlankRowsCheckbox" id="$store-blank-rows" /></td>
|
||||
<td colspan="2"><label for="$store-blank-rows">Store blank rows</label></td></tr>
|
||||
<tr><td width="1%"><input type="checkbox" bind="storeBlankCellsAsNullsCheckbox" id="$store-blank-cells" /></td>
|
||||
@ -37,7 +27,7 @@
|
||||
<td><label for="$include-file-sources">Store file source<br/>(file names, URLs)<br/>in each row</label></td></tr>
|
||||
</table></div></td>
|
||||
|
||||
<td colspan="2"><div class="grid-layout layout-tightest"><table>
|
||||
<td><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td width="1%"><input type="checkbox" bind="ignoreCheckbox" id="$ignore" /></td>
|
||||
<td><label for="$ignore">Ignore first</label></td>
|
||||
<td><input bind="ignoreInput" type="text" class="lightweight" size="2" value="0" />
|
||||
|
@ -80,12 +80,6 @@ Refine.LineBasedParserUI.prototype.getOptions = function() {
|
||||
};
|
||||
options.linesPerRow = parseIntDefault(this._optionContainerElmts.linesPerRowInput[0].value, 1);
|
||||
|
||||
if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") {
|
||||
options.lineSeparator = "\\n";
|
||||
} else {
|
||||
options.lineSeparator = this._optionContainerElmts.rowSeparatorInput[0].value;
|
||||
}
|
||||
|
||||
if (this._optionContainerElmts.ignoreCheckbox[0].checked) {
|
||||
options.ignoreLines = parseIntDefault(this._optionContainerElmts.ignoreInput[0].value, -1);
|
||||
} else {
|
||||
@ -127,11 +121,6 @@ Refine.LineBasedParserUI.prototype._initialize = function() {
|
||||
this._optionContainerElmts.linesPerRowInput[0].value =
|
||||
this._config.linesPerRow.toString();
|
||||
|
||||
var rowSeparatorValue = (this._config.lineSeparator == "\\n") ? 'new-line' : 'custom';
|
||||
this._optionContainer.find(
|
||||
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
|
||||
this._optionContainerElmts.rowSeparatorInput[0].value = this._config.lineSeparator;
|
||||
|
||||
if (this._config.ignoreLines > 0) {
|
||||
this._optionContainerElmts.ignoreCheckbox.attr("checked", "checked");
|
||||
this._optionContainerElmts.ignoreInput[0].value = this._config.ignoreLines.toString();
|
||||
|
@ -49,15 +49,7 @@
|
||||
</table></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td colspan="2">Rows are separated by</td></tr>
|
||||
<tr><td width="1%"><input type="radio" name="row-separator" value="new-line" id="$row-separator-new-line" /></td>
|
||||
<td><label for="$row-separator-new-line">new line characters \n</label></td></tr>
|
||||
<tr><td width="1%"><input type="radio" name="row-separator" value="custom" id="$row-separator-custom" /></td>
|
||||
<td><label for="$row-separator-custom">custom</label>
|
||||
<input bind="rowSeparatorInput" type="text" class="lightweight" size="5" /></td></tr>
|
||||
<tr><td colspan="2">Escape special characters with \</td></tr>
|
||||
</table></div></td>
|
||||
<td> </td>
|
||||
|
||||
<td><div class="grid-layout layout-tightest"><table>
|
||||
<tr><td width="1%"><input type="checkbox" bind="guessCellValueTypesCheckbox" id="$guess" /></td>
|
||||
|
@ -65,12 +65,6 @@ Refine.SeparatorBasedParserUI.prototype.getOptions = function() {
|
||||
encoding: $.trim(this._optionContainerElmts.encodingInput[0].value)
|
||||
};
|
||||
|
||||
if (this._optionContainer.find("input[name='row-separator']:checked")[0].value === "new-line") {
|
||||
options.lineSeparator = "\\n";
|
||||
} else {
|
||||
options.lineSeparator = this._optionContainerElmts.rowSeparatorInput[0].value;
|
||||
}
|
||||
|
||||
switch (this._optionContainer.find("input[name='column-separator']:checked")[0].value) {
|
||||
case 'comma':
|
||||
options.separator = ",";
|
||||
@ -140,11 +134,6 @@ Refine.SeparatorBasedParserUI.prototype._initialize = function() {
|
||||
});
|
||||
});
|
||||
|
||||
var rowSeparatorValue = (this._config.lineSeparator == "\\n") ? 'new-line' : 'custom';
|
||||
this._optionContainer.find(
|
||||
"input[name='row-separator'][value='" + rowSeparatorValue + "']").attr("checked", "checked");
|
||||
this._optionContainerElmts.rowSeparatorInput[0].value = this._config.lineSeparator;
|
||||
|
||||
var columnSeparatorValue = (this._config.separator == ",") ? 'comma' :
|
||||
((this._config.separator == "\\t") ? 'tab' : 'custom');
|
||||
this._optionContainer.find(
|
||||
|
Loading…
Reference in New Issue
Block a user