Skip to content

Commit ab28bc5

Browse files
sql-execute refactor
tsv option (LLM friendly)
1 parent c94620a commit ab28bc5

2 files changed

Lines changed: 266 additions & 168 deletions

File tree

api/src/org/labkey/api/util/PageFlowUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,6 +2676,16 @@ private static boolean shouldEscapeForExport(@NotNull String value)
26762676
return StringUtils.containsAny(value,",\"");
26772677
}
26782678

2679+
/// Generate one row of tab-delimited output using RFC 4180 quoting rules.
2680+
/// Fields containing tabs, newlines, or double quotes are enclosed in double quotes,
2681+
/// with embedded double quotes escaped by doubling.
2682+
public static String joinValuesWithTabs4180(@NotNull List<String> values)
2683+
{
2684+
return values.stream()
2685+
.map(value -> null == value ? "" : StringUtils.containsAny(value, "\t\n\r\"") ? "\"" + Strings.CS.replace(value, "\"", "\"\"") + "\"" : value)
2686+
.collect(Collectors.joining("\t"));
2687+
}
2688+
26792689

26802690
/**
26812691
* Issue 52925: App export to csv/tsv ignores filter with column containing double quote

0 commit comments

Comments
 (0)