Skip to content

Commit

Permalink
Bug: Preview pipe delimited fields in the map fields dialog
Browse files Browse the repository at this point in the history
If the file contained a delimiter that wasn't the default ',' but one of the fields
contained a comma (e.g. 12345|foo,bar) then we would detect a different
number of columns in each row, causing the dialog to fail to render.

This fix simply substitutes "n/a" in the preview (but not the data)
to allow the dialog to render and the customer to fix the delimiter.

Reviewed-by: TBD

QA: Verified with recent NYC upload
  • Loading branch information
spaceballone committed Oct 26, 2015
1 parent 26db0e0 commit 2d6dcce
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/com/socrata/datasync/model/CSVModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ public void setValueAt(Object value, int row, int col){
public String getColumnPreview(int columnIndex, int itemsToPreview){
StringBuffer buf = new StringBuffer();
for (int i = 0; i < Math.min(itemsToPreview,getRowCount()); i++){
buf.append(getValueAt(i,columnIndex));
Object value = "N/A";
try
{
value = getValueAt(i,columnIndex);
}
catch (ArrayIndexOutOfBoundsException e){
System.out.println("Row contains different number of columns than expected. Rows with missing data will be displayed as \"N/A\" in the map fields dialog");
}
buf.append(value);
if (i+1 < Math.min(itemsToPreview,getRowCount()))
buf.append(", ");
}
Expand Down

0 comments on commit 2d6dcce

Please sign in to comment.