Skip to content

Commit ea2d5fa

Browse files
committed
strip dead code
1 parent 39fe3af commit ea2d5fa

1 file changed

Lines changed: 26 additions & 37 deletions

File tree

forumQuestions/pq/2024-03 - Using Pairs of Strict Splitters to Simplify Your Parsing Logic -- expanded.pq

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,7 @@ let
1818
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Text", type text}}),
1919

2020

21-
// ProcessRows = ( source as table ) => [
22-
// schema_info = Record.Type,
23-
// Col_Info = Table.AddColumn(
24-
// source, "Split.Dash3",
25-
// (row) as record =>
26-
// SplitBy_Dash3( row[RawText] ),
27-
// schema_info
28-
// ),
29-
// Result = SplitBy_Dash3( Col_Info ),
30-
// Result_Text = _( Result ),
31-
// return = Result_Text
32-
// ],
33-
21+
// stricter split
3422
SplitBy_Dash3 = (string as text) as any => [
3523
ExpectedLength = 3,
3624
SplitFunc = Splitter.SplitTextByEachDelimiter(
@@ -46,7 +34,7 @@ let
4634
]
4735
][return],
4836

49-
// basically duplcate except the parameter
37+
// basically the same as SplitBy_Dash3, duplcate except the parameter
5038
SplitBy_MixedDash3 = (string as text) as any => [
5139
ExpectedLength = 3,
5240
SplitFunc = Splitter.SplitTextByEachDelimiter(
@@ -62,19 +50,17 @@ let
6250
]
6351
][return],
6452

65-
66-
67-
Summary = [
68-
// Was = ProcessRows( Rows ),
69-
Rows = #"Changed Type",
70-
OneRow = Rows{0}?,
71-
OneText = OneRow[Text]?,
72-
Try1_Dash3_t = OneText,
73-
z__ = _( [ name = "bob", id = 999 ]),
74-
Try1_Dash3 = SplitBy_Dash3( OneText ),
75-
Try1_Dash3_ = _( OneText )
76-
],
77-
Rows = Summary[Rows],
53+
// Summary = [
54+
// // Was = ProcessRows( Rows ),
55+
// Rows = #"Changed Type",
56+
// OneRow = Rows{0}?,
57+
// OneText = OneRow[Text]?,
58+
// Try1_Dash3_t = OneText,
59+
// z__ = _( [ name = "bob", id = 999 ]),
60+
// Try1_Dash3 = SplitBy_Dash3( OneText ),
61+
// Try1_Dash3_ = _( OneText )
62+
// ],
63+
Rows = #"Changed Type",// Summary[Rows],
7864

7965

8066
// get the crumbs, else throw when it's valid
@@ -86,23 +72,26 @@ let
8672
(type { text } )
8773
),
8874

89-
// error if fields are ever missing:
75+
// You can add the {0}? operator if you want to coerce missing items as null values
9076
Col_LineAsRecord = Table.AddColumn(
9177
Col_Step1, "Step2",
9278
(row) => [
9379
Crumbs = row[Step1],
94-
SplitBy_TwoWhitespace = Splitter.SplitTextByWhitespace(
95-
QuoteStyle.None
96-
),
97-
Id = Crumbs{0},
98-
Name = Crumbs{1},
99-
YearEnd = Crumbs{2},
80+
// SplitBy_TwoWhitespace = Splitter.SplitTextByWhitespace(
81+
// QuoteStyle.None
82+
// ),
83+
Id = Text.Trim( Crumbs{0} ),
84+
Name = Text.Trim( Crumbs{1} ),
85+
YearEnd = Text.Trim( Crumbs{2} ),
10086
// Name2 = SplitBy_TwoWhitespace( Crumbs{1} ),
10187
// CrumbsWhite = SplitBy_TwoWhitespace( row[Name] ),
10288
NameWithoutYear = Text.BeforeDelimiter( Name, " ", Occurrence.Last ),
103-
YearStart = Text.AfterDelimiter( Name, " ", Occurrence.Last ),
104-
return = [
105-
Id = Id, Name = NameWithoutYear, YearStart = YearStart, YearEnd = YearEnd
89+
YearStart = Text.AfterDelimiter( Name, " ", Occurrence.Last ),
90+
return = [
91+
Id = Id,
92+
Name = NameWithoutYear,
93+
YearStart = YearStart,
94+
YearEnd = YearEnd
10695
]
10796
][return],
10897
Record.Type

0 commit comments

Comments
 (0)