Code Files

CSV2Tagged-Field.awk

Generated on Tue Dec 05 17:39:06 Eastern Standard Time 2006 from CSV2Tagged-Field.awk


# Program:	CSV2TAGGED-FIELD.AWK
# Purpose:	Function to parse fields in a CSV file and write a generic Tagged-Field format file
# Date:		10 June 2003
# Author:	Bob Jonkman <bjonkman@sobac.com>

# Copyright 2008 Bob Jonkman and/or SOBAC Microcomputer Services

#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.




BEGIN	{ 	FS="";
		OFS= "" ;
		ORS= "" ;
		FIELD_DELIMITER = "\"" ; 
		FIELD_SEPARATOR = "," ;
		numfields = 0;
	}


##### Read the headers #####

NR == 1	{	parsecsv($0,headers);
	}

##### End of Read the Headers #####

	
NR > 1	{	
		nmflds = parsecsv($0,field);

		# print the field
		print("\nRecord " NR "    " nmflds " Fields\n") ;
		for (i = 1; i <= nmflds; i++)
			print(headers[i] " = " field[i] "\n" ) ;
	}

END	{ }	

# EOF: CSV2TAGGED-FIELD.AWK
   

1 files processed.