Feb 14, 2012 12:26 PM
Delimiter for space and fixed width in nzload?
-
Like (0)
Can anyone tell me what is the delimiter for space and fixed width files in nzload?
For tab delimiter it is \t, but can't seem to figure out for space and fixed width files.
Thanks
A fixed width file doesn't have delimiters, that is the entire point of fixed width. I'm not sure what you mean when you say space, do you mean the standard space character? That would be -delim 32 (you can use the ascii character code with the -delim parameter)
What do you mean by delimiter for space and fixed width files? There is no column delimiter for fixed width files. You should create a control file which defines the record layout.
What is the control script for fixed width files? I'm familar with sqlloader control file scripts, but can't seem to figure out in nzload. Can you please show me some sample control file scripts in nzload for fixed width. Is there any way in nzload control script to load certain columns from a flat file?
Here you go
nzload -u ${NZ_USER} -pw ${NZ_PWD} -host ${NZ_HOST} -db ${NZ_DB -t ${TGT_TABLE} -cf ${CTL_FILE_NM} -lf ${LOGFILE} -bf ${BADFILE} 2> ${LOAD_TBL_ERR}
Control file
DATAFILE <Specfiy the file name>
{
format fixed
maxerrors 0
layout (
COLUMN1 char(1) bytes 1,
COLUMN2 char(5) bytes 5,
COLUMN3 char(5) bytes 5,
COLUMN4 char(11) bytes 11,
COLUMN5 varchar(30) bytes 30,
COLUMN6 varchar(6) bytes 6,
COLUMN7 varchar(2) bytes 2,
COLUMN8 varchar(1) bytes 1,
COLUMN9 varchar(8) bytes 8,
COLUMN10 varchar(8) bytes 8,
COLUMN11 varchar(8) bytes 8,
COLUMN12 varchar(1) bytes 1,
COLUMN13 varchar(40) bytes 40
)
}
Raja,
I'm in process of loading a comma delimited file, but the file contains 14 columns and I only want to load 10 columns out of it. What is the control script to do this? Can I load this file into a table which contains more columns than an actual raw file?
NZLoad is a very simple tool with very few features. It expects the file content to match the definition, so you cannot selectively exclude columns.
There are two different approaches you can take to perform transformation on the source:
1. Use NZLoad to get the data in as-is from the source, then use SQL to move what you want, where you want.
2. Define the source as an external table (which is what NZLoad does anyway) and use SQL to read the source and place the data where you want it.
Raja,
I get following errors while loading a fixed width file.
Error: parse error: unexpected keyword or token 'format' is found on line 3.
Try using 'nzload -h' for more information.
Here is my nzload script:
cf_file = "/load/controlfile/test.ctl"
host= "hostname"
db="dbname"
user="username"
pw="password"
`nzload -host $host -db $db -u $user -pw $pw -cf $cf_file -maxerrors 10 -lf test.log -bf test.bad`
controlfile script:(test.ctl)
DATAFILE data_load.txt
{
format fixed
tablename test_load
layout (
ID char(10) bytes 10,
FNAME char(14) bytes 14,
LNAME char(14) bytes 14,
ZIP char(5) bytes 5
)
}

