Forum Discussion
Csv into table
- 2 years ago
hello, RamblingFire one of possible ways to do this is to import csv into PQ, promote headers, find a position of non-compliant part using headers (Table.PositionOf), split your table (Split.At), add compliant / not compliant status column and combine tables back together.
let csv_import = #table( {"h1", "h2", "h3"}, {{"a", "b", "c"}, {"d", "e", "f"}, {"h1", "h2", "h3"}, {"a", "b", "c"}, {"a", "b", "c"}} ), cols = List.Buffer(Table.ColumnNames(csv_import)), split = Table.SplitAt( csv_import, Table.PositionOf( csv_import, Record.FromList(cols, cols) ) ), result = Table.AddColumn(split{0}, "Status", each "Compliant") & Table.AddColumn(Table.PromoteHeaders(split{1}), "Status", each "Not Compliant") in result
Hi AlienSx,
Thanks so much for this, it looks exactly what I need. Can you share or provide me with a pointer where I can enter the above script?
- RamblingFire2 years agoRegular Visitor
Thank you, what stands out to me is the fact that data is in the query, how would this apply to a second file with other data?
- RamblingFire2 years agoRegular Visitor
Ahha I think I get it, the split function uses the column headers irrelevant to where they appear. The data is in the query for example and I could just reference the table name as per 2nd example in video