[CDBUG-talk] Weird scripting question

Dustin J. Mitchell dustin at v.igoro.us
Fri Feb 10 17:45:44 EST 2017

Could that be `111` and then `111a`, etc.?  If so, you might add each
employee id to a data structure in awk, appending something to the id if
it's already in that data structure until finding a unique string.

How do that in awk, I don't know -- I haven't read sed&awk for a long time!!


2017-02-10 12:56 GMT-05:00 Jaime <jaime at snowmoon.com>:

> I have a weird scripting question.  I have two vendors:  One is providing
> a CSV file of people, their ID#s, the building where they work, etc.;  the
> other is requesting a CSV file of that data in a different format.  I'm
> currently doing the conversion between these two formats via awk inside a
> bash script.  (The script also grabs the first file over SFTP and uploads
> the post-processed file to another server via SFTP.)
> So I have a data file from the first vendor that says:
> Fred,Flinstone,111,High School
> Fred,Flintstone,111,Middle School
> Betty,Rubble,112,MiddleSchool
> I need to send it to the vendor that automates emergency phone calls (in
> the event of closure due to snow and things like that.)  The second vendor
> will only list Fred Flintstone as working in the Middle School, since the
> two lines have the same employee ID#.
> I was told by the second vendor to change the lines to be more like:
> Fred,Flintstone,a111,High School
> Fred Flintstone,b111,Middle School
> Betty,Rubble,112,Middle School
> Betty has the same ID# because there is only one record for her.  Fred
> gets "a" and "b" prepended because there are two entries and we need to be
> sure they have different ID#s.
> Any idea how to do this?  Is it even possible with awk?
> Jaime
> _______________________________________________
> CDBUG-talk mailing list
> CDBUG-talk at lists.nycbug.org
> http://lists.nycbug.org/mailman/listinfo/cdbug-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/cdbug-talk/attachments/20170210/b7b3e270/attachment.html>

More information about the CDBUG-talk mailing list