[CDBUG-talk] Weird scripting question

Jaime jaime at snowmoon.com
Fri Feb 10 12:56:13 EST 2017

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

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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org/pipermail/cdbug-talk/attachments/20170210/8cb787d8/attachment.html>

More information about the CDBUG-talk mailing list