Skip to content

Commit

Permalink
Add group and count db stringer
Browse files Browse the repository at this point in the history
  • Loading branch information
nh43de committed Nov 1, 2022
1 parent 8c1f6da commit 397bb35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 1 addition & 2 deletions DataToolChain.Ui/DataUploader/DataUploadHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public static async Task Upload(SqlConnection sqlc, IDataReader sourceReader, Da
{

var reader = sourceReader;



if (string.IsNullOrWhiteSpace(filterNullColumns) == false)
{
var cols = filterNullColumns.Split(",");
Expand Down
12 changes: 12 additions & 0 deletions DataToolChain.Ui/DbStringer/RegexReplacerCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ public static RegexReplacerCollection DefaultReplacerCollection
new RegexReplacement("To Lower", s => s.ToLower()),
new RegexReplacement("To Upper", s => s.ToUpper()),

new RegexReplacement("Group and Count", s => Regex.Split(s, "\r\n?")
.Select(p => p.Trim())
.GroupBy(p => p)
.Select(p => new
{
Count = p.Count(),
Key = p.Key
})
.OrderByDescending(p => p.Count)
.Select(p => p.Key + '\t' + p.Count)
.JoinStr("\r\n")),

new RegexReplacement("Trim", s => s.Split('\r').Select(x => x.Trim()).JoinStr("\r\n")),
new RegexReplacement("Sort Alphabetically", s => Regex.Split(s, "\r\n?").OrderBy(x => x).JoinStr("\r\n")),
new RegexReplacement("Sort by Length", s => Regex.Split(s, "\r\n?").OrderBy(x => x.Length).ThenBy(x => x).JoinStr("\r\n")),
Expand Down

0 comments on commit 397bb35

Please sign in to comment.