Created
April 7, 2015 14:44
-
-
Save CurtHagenlocher/10eb34d0fc3a48480fea to your computer and use it in GitHub Desktop.
This sample uses a header consisting of dashes to identify where the column boundaries are and then splits the file by those boundaries.
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
let | |
Source = Table.FromColumns({Lines.FromBinary(Web.Contents("http://www.aer.ca/data/WELLS/SPUDTHU.TXT"),null,null,1252)}), | |
Header = List.First(List.Select(Source[Column1], each Text.StartsWith(_, "--"))), | |
Positions = Text.PositionOf(Header, " ", -1), | |
Length = Text.Length(Header), | |
Lengths = List.Generate( | |
() => 0, | |
(i) => i <= List.Count(Positions), | |
(i) => i + 1, | |
(i) => | |
let | |
start = if i = 0 then -1 /* to capture trailing space */ else Positions{i-1}, | |
end = if i = List.Count(Positions) then Length else Positions{i} | |
in | |
end - start), | |
Split = Table.SplitColumn(Source,"Column1",Splitter.SplitTextByLengths(Lengths)) | |
in | |
Split |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment