unpivot_weekly_csv
Stream-unpivot wide CSVs with weekly columns into tall CSVs one row at a time, avoiding Power Query out-of-memory errors. Optionally keep only rows in a chosen scope.
Instructions
Stream-unpivot a WIDE CSV (one column per week, e.g. '23/06/2024_SALES','23/06/2024_VOLUME') into a TALL CSV (keys + WeekKey + one column per measure), one row at a time. USE THIS when a CSV has hundreds of period columns and Power Query's Table.UnpivotOtherColumns runs the mashup OUT OF MEMORY on big files - the tall CSV then loads with Csv.Document() and no transform. Optional 2-pass scope filter keeps only rows whose scopeColumn value appears for filterColumn=filterValue (e.g. 'the categories the supplier sells in'). Empty weeks are skipped.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inCsv | Yes | absolute path to the wide source .csv | |
| outCsv | No | output .csv path (omit to write '<name> (long).csv' next to source) | |
| measures | Yes | measures as suffix:outName, comma-separated, e.g. "_SALES:Sales,_VOLUME:Volume" | |
| keyColumns | Yes | comma-separated key columns to keep, e.g. "PRODUCT_CODE,STORE_CODE" | |
| filterValue | No | optional filter value to keep (the value within the filter column) | |
| scopeColumn | No | optional scope column to keep in-scope rows, e.g. "National Merchandise Category" | |
| filterColumn | No | optional filter column for the scope pass, e.g. "Supplier Name" |