I use awk scripts to help automate a data import routine into a MySQL database. The data is formatted incorrectly for the database and the following script is used for conversion (running on a hosted BSD server...)
The ro_date output returns and extra character string... A "^M", like this: 2009^M/7/6 which I assume is an end-of-line marker in the original data; but, I don't know how to resolve this in my output.
Any suggestion would be most appreciated,
TIA,
-A
Code:
BEGIN{FS=",";OFS=",";
}
NR > 1 {
$9=tolower($9);
gsub(" work","",$9);
gsub(" home","",$9);
gsub(" other","",$9);
gsub("\"","");
gsub("\ 0:00:00","");
gsub("-","",$7);
gsub("-","",$8);
gsub(/[\177-\377]/, "");
ro_date="";
if ($14 !="")
{
z=split($14,dt,"/");
year= dt[3];
month= dt[1];
day= dt[2]
ro_date = year"/"month"/"day;
}
if($1 !="") {
print $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, ro_date ; } }
The ro_date output returns and extra character string... A "^M", like this: 2009^M/7/6 which I assume is an end-of-line marker in the original data; but, I don't know how to resolve this in my output.
Any suggestion would be most appreciated,
TIA,
-A