Article | Vectors, Strings and Transform Functions

Hardly, one would find blogs/articles/tutorials on Ab Initio transformation functions. I introduce you to another set of functions which will make you understands vectors in a different way.


Suppose, there is data file whose record format has 5 fields, namely A, B, C and D. Let us give them useful meaning, A – student_id, B – student_nm, C – sem_num, D – subject_name, E – marks.

There will be a possibility that combination of A, B remains the same across several records in the data, whereas remaining columns may change. For instance, student Mr. X has 3 subjects in semester 1, whereas Mr. Y has 4 subjects in semester 2 and Mr. Z also having 4 subjects, but in semester 2.

What if there’s a need to consolidate so much information in a single record and present it as a report. This report must have Student Name, Student Id, Semesters covered so far (comma-delimited), Courses taken (pipe-delimited) and Average Marks.

Transformation Function

The following transformation rule uses string_join() and vector_sort_dedup_first() to solve the purpose, i.e. to get an output string of pipe-delimited vector elements.

out.target_field :: string_join(vector_sort_dedup_first(in), "|");

One can create user-defined function which wraps the above functionality, which would be generic enough to be used in any transformation where vectors are involved.

out :: get_delim_vec_ele(input_vec, delim)
   out :: string_join(vector_sort_dedup_first(input_vec), delim);

This function takes 2 arguments, input vector and delimiter to form delimited string of vector elements as output. So, your actual transformation can now look like;

out.target_field :: get_delim_vec_ele(in, "|");

Hope this helps 🙂


Article | Automate Backup for IE Favorites

Before diving deep into the world of shell scripting, I had ventured with batch scripting on Windows XP machine. Well, recently I had to format Windows 7 running on Dell Studio laptop.

In doing so, I forgot to keep backup of the browser bookmarks/favorites, even though Chrome/Firefox provide options to export them. However, I had been using IE lately and kept rather few, yet important links bookmarked.So, I rarely cared about backing them up until recently.

Why not Google?

Well, I did few days back and found the following link useful;

As most of the Windows users would be knowing the OS keeps your favorites/bookmarks under following directory structure;

Windows XP – C:\Documents and Settings\<username>\Favorites

Windows 7 – C:\Users\<username>\Favorites

Generally, Windows OS, be it XP or 7, would be installed in C drive, part of partitioned hard disk storage. So, I was wondering why not make use of the other partitions which are least impacted by crashing/formatting of the Operating System.

Also, keeping backup of the folder manually regularly would not be that easy, even though it is.

Why not automate the backup process?

This is what I think should be done (technically), by creating the following batch script;

:: Assuming the system has another partition as E drive

cd /d "E:"
rmdir /s /q Favorites
xcopy /s /f Favorites "E:\Favorites"

Now, I just have to save it as batch program, keep it on any drive other than the OS drive.

I tested it on Windows 7 and worked well.