Modifying LCM Resource Files

The Problem: LCM CSV Files are completely useless!

A client asked me to provide them with a nice, clean report that they could open in Excel to view group membership. I forwarded them the stock LCM output file with great shame. I then opened up my laptop and decided enough was enough and took to creating a better CSV.

Step 1: Figuring out the information you need.

Once you’ve completed an LCM migration and produced a Groups resource file, open it up. Everything above the first #group_children token has group information but is not related to group membership. So we’re going to get rid of that. Then we’ll get rid of blank lines, the #group_children tokens, and every header line, which includes:

  • id
  • group_id
  • group_provider
  • user_id
  • user_provider

Step 2: Look at this code

Here is the complete batch script that modifies the stock LCM resource file for groups:


Instead of copying and pasting the text again and agian, I’m just going to refer to the code by line number.

Line 1 sets the file name. The name of the file produced by an LCM migration for Native Directory groups is Groups.csv. With this batch I’m assuming:

  1. Your file name is still Groups.csv.
  2. The batch is in the same directory as Groups.csv.

If (1) is not true, change the file name. If (2) is not true, simply modify the file variable to reflect the directory in which the csv file resides and change the file name if it’s no longer Groups.csv.

Line 3 deletes everything up to and including the first #group_children token and saves the results in the same Groups.csv file.
Line 5 removes all the #group_children tokens and header lines from the file and writes the results to Groups.txt.
Line 7 replaces all the text in Groups.csv with one header line.
Line 9 copies the contents of Groups.txt under the header line from Line 7 while removing all blank lines.
Line 11 cleans up Groups.txt as it is no longer needed.
More coming soon…
I don’t have the time for screen caps or a demonstration right now, but I’ll develop a few more batches (or perhaps make this one more generic) and give more detailed information in an upcoming post. I’m going to provide this batch to my client so that they can run it to produce reports. By putting it at the tail end of an automated migration, the process becomes seamless. Happy pivoting!