Import csv files via PowerShell

CSV files along with XML and JSON files can easily be imported into a Profitbase Studio data warehouse by way of PowerShell scripts that does the job of extracting and moving the data.

This allows for very efficient loading of the data while SSIS is no longer a requirement. 

Adding a new CSV data source:

1. In the Navigator Pane; right click 'Data Sources' and then click 'New Data Source'. 

2014-06-04_09_33_42-Store.png

 

2. Select 'Add empty' and click 'Next'.

 

3. Enter the name and type of your new Data Source. Click 'Next'.

2014-06-04_09_38_08-Store.png

 

4. Select 'Csv files via PowerShell' and specify csv file settings. Choose a 'Default File' and click 'View' to check a files row/column delimiters and text qualifiers. Click 'Next'.

PS6_CsvPoSh_Part1_SalesEx.PNG 

5. Add a new data source table. Specify settings. Click 'Finish'.

PS6_CsvPoSh_Part2_SalesEx.PNG

6. View source file data by using the 'View Source Table' button and perform column mapping by drag dropping column headers in the data viewer into the Source Expression field.

PS6_CsvPoSh_Part3_SalesEx.PNG


Fringe cases like changing csv file names and customized load of one or several tables can be handled by way of using a script extension to handle the loading of data.

1. Click the 'Edit' button next to the 'File name' drop down list. Copy the PowerShell script that is displayed.

PS6_CsvPoSh_Part4_SalesEx.PNG

2. Add a new script definition of type PowerShell script.

PS6_CsvPoSh_Part5_SalesEx.PNG

3. Paste the script into the Script Command of the new script definition. Instead of the hard coded file name; drag and drop the SOURCEFILENAME tag into the place where the file name was. The SOURCEFILENAME placeholder tag contains the file name specified in the data source table in context.

PS6_CsvPoSh_Part6_SalesEx.PNG

4. To use the custom script extension instead of the default load mechanism. Add it as a script extension.

PS6_CsvPoSh_Part7_SalesEx.PNG

5. Check the 'Use Script Extensions to load source data' option.

PS6_CsvPoSh_Part8_SalesEx.PNG