-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add feature type to csv export (#1157)
* add feature type to csv eport * fix value case * add CSVEncoder * formatting * update column name
- Loading branch information
1 parent
dd7792b
commit 4794d0d
Showing
2 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.maproulette.utils | ||
|
||
object CSVEncoder { | ||
def encodeRow(row: List[Any]): String = { | ||
row.map(escape).mkString(",") | ||
} | ||
|
||
private def escape(value: Any): String = { | ||
val strValue = value.toString | ||
if (strValue.contains(",") || strValue.contains("\"") || strValue.contains("\n")) { | ||
"\"" + strValue.replace("\"", "\"\"") + "\"" | ||
} else { | ||
strValue | ||
} | ||
} | ||
} |