Sunday 29 November 2015

How to Create '|' (Pipe) Delimited Files in Excel


Microsoft Excel is a very useful tool for data analysis. It supports import of data from various sources and formats into it for analysis. But, though it supports export of data in various common formats, it does not natively support export of data in a delimited text format with the delimiter other than Comma and Tab characters. This post explains how to get the excel data exported into a "|" (pipe) delimited text file.


Excel does not directly support export or saving the data delimited with a pipe or such other characters. It supports comma delimited files (.csv) or tab delimited files though. The csv file generator however uses the List Separator as set in the windows Regional Settings as the delimiter. With this you can change this value in the regional settings and the csv file option will now produce a delimited file with the delimiter of your choice as set in the regional settings. For those not familiar with the regional settings, here is how to get this accomplished:

If you are using Windows 8 or 8.1, you will find the Regional Settings option under the "Clock, Language and Region"  category.

Click on the Additional Settings button in the Formats tab of the Regional Settings dialogue box. In the Numbers tab of the resulting dialogue box, you will find the field List Separator (Highlighted in the image. By default, it displays ","(comma). Now set it to a character that you need the files to be delimited with. For instance, if you want export a pipe delimited text file from excel, enter the charcter "|" in this field and apply the change.

You are done. Close and re-open Excel with the data that you want to export. Now use the Save As option to save the sheet as a csv file (.csv). This will now produce a text file delimited with the pipe character. Unless you regularly use pipe as the delimiter, you may want to set it back to comma, so that it does not impact any other operations that dependent on the List Separator field.

Sunday 20 September 2015

Powershell Script for Cleaning up Old Files


I am working on a project that creates 100s of files every hour which has led to creation of over few thousand files in a week. Due to the very high number of files, Explorer takes so long to list the files in the folder. As this could fill up the storage pretty fast, I need to delete files older than 7 days. Please suggest me how best to accomplish this, preferably using PowerShell and leveraging the Scheduled Tasks.

By: Anonymous


Powershell is the way to go for these kind of tasks. For deleting old files, the following script will do the job:

Get-ChildItem –Path <Base Folder> –Recurse | Where-Object CreationTime –lt (Get-Date).AddDays(-7) | Remove-Item

Replace the <Base Folder> with the actual base folder  that need to be looked up for this task. Simiarly, you may observe the from the above script, this will delete the files based on the time of creation of the file. If you want to use the last modified time, replace the CreationTime with LastWriteTime

The above script can be executed from the PowerShell prompt or can be scheduled to run automatically using the Windows Task Scheduler. There are couple of things that you should take care of while scheduling:

  • By default, the deletion will fail as the execution policy may not permit the deletion. To override this set the parameter ExecutionPolicy to bypass
  • You may want to add the parameters - noninteractive. to enable to run automatically without needing user action. 
  • Do not place the script itself in the program field, Instead save the script as a .ps1 file and pass the script file with fully qualified path as a parameter in the parameter field.

Typically, the following should be added to the parameter field:

-noninteractive –nologo -ExecutionPolicy Bypass -command "& 'c:\datafiles\cleanup.ps1'"

Needless to mention that the progrm / script field shall contain the PowerShell executable with its fully qualified path, which will be like this:

You may also want to have a look at the clean up script on the TechNet site, which has many more capabilities, like crating a log of files deleted and so on.

Friday 26 June 2015

SSRS Report Builder 3.0 - How to avoid page breaks in Report Viewer


The Report Viewer displays the tabular reports with pagination. This is inconvenient to users as they have to click on the page navigator to browse through the report. Is there a way to have the report viewer display all the rows in one view, so that users will find it convenient to browse through the report by just scrolloing up and down?

By: Muthu Saravanan


Use the Interactive Size property of the report to overcome this. This property will not however show up in the Report Properties dialog. This will be available on the Properties Pane, which shows up ususally on the right side of the screen. If it is not showing up, check the options under the View menu. To have all records in single view without pagination, set the Height under Interactive Size to 0 cm.

This setting is effective for display in the report viewer only. Page breaks in print and other export formats will be based on the Page Size rather than the Interactive Size property.

Friday 6 March 2015

Whitelisting email or domain in Gmail


How to whitelist or blacklist an email domain in gmail?

By: Radhakrishnan Ravi


Google has a might spam handler and does a very decent job. However, if you want to put a rule to either whitelist or blacklist, use the filter options provided under settings menu. It is simple and the following steps will take you through in implementing a filter of your choice.

Choose the Settings menu from the Settings drop down menu on the top right beneath your profile picture.

Select the Filter Tab, which will list the filters and will have a link at the bottom captioned ''Create a New Filter". As you may observe, you have an option to import filters as well using the "Import Filter" link.

Clicking the create filter will take you to the advanced search window as in the image on the right. Alternatively this search window can be accessed using the tiny drop down icon provided on the right side of the search box within gmail. Basically, you will have to decide on the search criteria to apply the filter for. i.e, if you want to whitelist the domain, enter the domain name in the From field of the search window. Upon entering a valid search criteria, you will find the link "Create a filter with this search" enabled.

Click on this and you will see a Filter Dialogue window as in the image on the left. The options provided are self explanatory and choose appropriate action you want to apply for the chosen search criteria. For instance, if you want to white list the entered domain, select the option "Never send it to Spam" and then click on the Create Filter button at the bottom. Similarly, if you want to permanently delete emails from a specific sender, you may choose the delete option here.

The filters so added will appear in under the Filter tab of the settings screen. You will then have the option to remove or modify the filters  as well.