|
18 | 18 | #"Changed Type" = Table.TransformColumnTypes(Source,{{"Text", type text}}), |
19 | 19 |
|
20 | 20 |
|
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 |
34 | 22 | SplitBy_Dash3 = (string as text) as any => [ |
35 | 23 | ExpectedLength = 3, |
36 | 24 | SplitFunc = Splitter.SplitTextByEachDelimiter( |
|
46 | 34 | ] |
47 | 35 | ][return], |
48 | 36 |
|
49 | | - // basically duplcate except the parameter |
| 37 | + // basically the same as SplitBy_Dash3, duplcate except the parameter |
50 | 38 | SplitBy_MixedDash3 = (string as text) as any => [ |
51 | 39 | ExpectedLength = 3, |
52 | 40 | SplitFunc = Splitter.SplitTextByEachDelimiter( |
|
62 | 50 | ] |
63 | 51 | ][return], |
64 | 52 |
|
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], |
78 | 64 |
|
79 | 65 |
|
80 | 66 | // get the crumbs, else throw when it's valid |
|
86 | 72 | (type { text } ) |
87 | 73 | ), |
88 | 74 |
|
89 | | - // error if fields are ever missing: |
| 75 | + // You can add the {0}? operator if you want to coerce missing items as null values |
90 | 76 | Col_LineAsRecord = Table.AddColumn( |
91 | 77 | Col_Step1, "Step2", |
92 | 78 | (row) => [ |
93 | 79 | 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} ), |
100 | 86 | // Name2 = SplitBy_TwoWhitespace( Crumbs{1} ), |
101 | 87 | // CrumbsWhite = SplitBy_TwoWhitespace( row[Name] ), |
102 | 88 | 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 |
106 | 95 | ] |
107 | 96 | ][return], |
108 | 97 | Record.Type |
|
0 commit comments