#****************************************************************************
#  ##   ##         #####   #####  ##     **       NoSQL RDBMS - ucfirst     *
#  ###  ##        ####### ####### ##     **        $Revision: 2.1 $			*
#  #### ##        ###     ##   ## ##     ************************************
#  #######  ####  #####   ##   ## ##     **      Carlo Strozzi (c) 1998     *
#  ####### ######   ##### ## # ## ##     ************************************
#  ## #### ##  ##     ### ##  ### ##     **           Written by            *
#  ##  ### ###### ####### ######  ###### **          Carlo Strozzi          *
#  ##   ##  ####   #####   #### # ###### **     e-mail: carlos@linux.it     *
#****************************************************************************
#   NoSQL RDBMS, Copyright (C) 1998 Carlo Strozzi.                          *
#   This program comes with ABSOLUTELY NO WARRANTY; for details             *
#   refer to the GNU General Public License.                                *
#****************************************************************************
#
#  Change casing of column names.
#
#  Turns to lower-case the column names and capitalizes the first letter
#  of each one, to improve column name readability.
#
#  This NoSQL operator reads a table STDIN and writes a table to STDOUT.
#
########################################################################

########################################################################
# BEGIN block
########################################################################

BEGIN { NULL = ""; FS = OFS = "\t"; }

########################################################################
# Main loop
########################################################################

# Column names.
NR == 1 \
{
  while ( ++i <= NF )
  {
	first_letter = substr( $i, 1, 1 )
	others = substr( $i, 2 )
	out_rec = out_rec OFS toupper( first_letter ) tolower( others )
  }

  # Strip extra leading tab.
  sub( /^\t/, NULL, out_rec ); print out_rec; next
}

{ print }

