Sponsored Content
Top Forums Shell Programming and Scripting use SQL loader to dump a fixed length file in to DB Post 302139967 by nir_s on Wednesday 10th of October 2007 05:53:06 AM
Old 10-10-2007
You can edit the control file of the sqlloader by the following:

Code:
LOAD DATA
INFILE <data_file_path_and_name>
INTO TABLE <table_name> (
<column_name> POSITION(<integer>:<integer>) <data_type>,
<column_name> POSITION(<integer>:<integer>) <data_type>,
<column_name> POSITION(<integer>:<integer>) <data_type>)

I.e:
LOAD DATA
   INFILE /tmp/load_data.dat
   INTO TABLE t1
     (col1 POSITION(1:5) ,
      col2 POSITION(6:9) , 
      col3 POSITION(10:13))

Regards,
Nir
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

creating a fixed length output from a variable length input

Is there a command that sets a variable length? I have a input of a variable length field but my output for that field needs to be set to 32 char. Is there such a command? I am on a sun box running ksh Thanks (2 Replies)
Discussion started by: r1500
2 Replies

2. Shell Programming and Scripting

convert fixed length file to CSV

Newbie Looking for a script to convert my input file to delimited text file. Not familier with AWK or shell programing. Below is sample record in my input file and the expected output format. My OS is HPUX 11.23. Thanks in advance for your assistance. tbtbs input file:... (12 Replies)
Discussion started by: tbtbs
12 Replies

3. UNIX for Dummies Questions & Answers

What the command to find out the record length of a fixed length file?

I want to find out the record length of a fixed length file? I forgot the command. Any body know? (9 Replies)
Discussion started by: tranq01
9 Replies

4. UNIX for Dummies Questions & Answers

Convert a tab delimited/variable length file to fixed length file

Hi, all. I need to convert a file tab delimited/variable length file in AIX to a fixed lenght file delimited by spaces. This is the input file: 10200002<tab>US$ COM<tab>16/12/2008<tab>2,3775<tab>2,3783 19300978<tab>EURO<tab>16/12/2008<tab>3,28523<tab>3,28657 And this is the expected... (2 Replies)
Discussion started by: Everton_Silveir
2 Replies

5. Shell Programming and Scripting

how to read fixed length flat file....

Hi Gurus, Thanks in advance... I am new to writing shell scripting and help me out reading a flat file with fixed length. I have a fixed length flat file with storename(lenth 6) , emailaddress(lenth 15), location(10). There is NO delimiters in that file. Like the following str00001.txt... (2 Replies)
Discussion started by: willywilly
2 Replies

6. Shell Programming and Scripting

Fixed length flat file extraction

Hii ,I am new to Unix ,i have a flat file which is (fixed length) sitting in unix,Which is holding the data for a table.I want to extract one column(length7-10) on the basis of another column(length13-15) and want only one single row Example: Below is the sample of flat file. 1111 AAAA 100 ... (4 Replies)
Discussion started by: laxmi1166
4 Replies

7. Shell Programming and Scripting

Replace Date in a fixed length file

Hello All, I working on ksh. I am using fixed length file. My file is like: ======== IXTTIV110827 NANTH AM IKSHIT ABCDEF 0617 IJAY NAND EENIG ZXYWVU 0912 AP OOK OONG PQRSTU100923 NASA DISH TTY ASDFG 0223 GHU UMA LAM QWERT 0111 ATHE SH THEW ======= From 7th to 12 is a date... (4 Replies)
Discussion started by: AnanthaDikshit
4 Replies

8. UNIX for Dummies Questions & Answers

Length of a fixed width file

I have a fixed width file of length 53. when is try to get the lengh of the record of that file i get 2 different answers. awk '{print length;exit}' <File_name> The above code gives me length 50. wc -L <File_name> The above code gives me length 53. Please clarify on... (2 Replies)
Discussion started by: Amrutha24
2 Replies

9. Shell Programming and Scripting

Fixed Length file from a SQL script

Hi, I have a DB2 UDB 9.7 SQL script, as follows: I need to pass the script into Unix and generate a fixed length file from this. Can someone kindly provide a script to achieve it? SELECT CAST(COALESCE(CL_ID,'000000000') AS CHAR(9)) AS CL_ID ,STATUS... (5 Replies)
Discussion started by: ebsus
5 Replies

10. Shell Programming and Scripting

Fixed length to delimited file conversion

Hi All, I need to convert a fixed length file to a delimited file with , (comma). But not all columns, some of the columns in the fixed files are used as fillers and I do not need that in the output file. test_fixed_len.txt I 0515 MR 394 I 0618 MR & MRS 942 I 0618 MR & MRS... (7 Replies)
Discussion started by: member2014
7 Replies
shp2pgsql(1)							      PostGIS							      shp2pgsql(1)

NAME
shp2pgsql - shapefile to postgis loader SYNTAX
shp2pgsql [options] shapefile [schema.]table DESCRIPTION
The shp2pgsql data loader converts ESRI Shape files into SQL suitable for insertion into a PostGIS/PostgreSQL database. Version: 1.1.5 (2006/10/06) USAGE
The <shapefile> is the name of the shape file, without any extension information. For example, 'roads' would be the name of the shapefile comprising the 'roads.shp', 'roads.shx', and 'roads.dbf' files. The <tablename> is the (optionally schema-qualified) name of the database table you want the data stored in in the database. Within that table, the geometry will be placed in the 'geo_value' column by default. OPTIONS
The loader has several operating modes distinguished by command line flags: (Note that -a, -c, -d and -p are mutually exclusive.) -d Drops the database table before creating a new table with the data in the Shape file. -a Appends data from the Shape file into the database table. Note that to use this option to load multiple files, the files must have the same attributes and same data types. -c Creates a new table and populates it from the Shape file. This is the default mode. -p Only produces the table creation SQL code, without adding any actual data. This can be used if you need to completely separate the table creation and data loading steps. -D Use the PostgreSQL "dump" format for the output data. This can be combined with -a, -c and -d. It is much faster to load than the default "insert" SQL format. Use this for very large data sets. -s <SRID> Creates and populates the geometry tables with the specified SRID. -g <geometry_column> Specify the name of the geometry column (mostly useful in append mode). -k Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are usually all UPPERCASE. -i Coerce all integers to standard 32-bit integers, do not create 64-bit bigints, even if the DBF header signature appears to warrant it. -S Generate simple Geometries instead of MULTIgeometries. Shape files don't differ between LINESTRINGs and MULTILINESTRINGs, so shp2pgsql generates MULTILINESTRINGs by default. This switch will produce LINESTRINGs instead, but shp2pgsql will fail when it hits a real MULTILINESTRING. The same works for POLYGONs vs. MULTIPOLYGONs. -w Output WKT format, for use with older (0.x) versions of PostGIS. Note that this will introduce coordinate drifts and will drop M values from shapefiles. -W <encoding> Specify the character encoding of Shapefile's attributes. If this option is used the output will be encoded in UTF-8. -I Create a GiST index on the geometry column. -N <policy> Specify NULL geometries handling policy (insert,skip,abort). -? Display version and usage information. INSTALLATION
To compile the program from source, simply run "make" in the source directory. Then copy the binary in your shell search path (or wherever you like). This text is also available as a man page in the ../doc/man/ directory, ready for copying it into the manual search path on unixoid systems. EXAMPLES
An example session using the loader to create an input file and uploading it might look like this: # shp2pgsql shaperoads roadstable roadsdb > roads.sql # psql -d roadsdb -f roads.sql A conversion and upload can be done all in one step using UNIX pipes: # shp2pgsql shaperoads roadstable roadsdb | psql -d roadsdb AUTHORS
Originally written by Jeff Lounsbury <jeffloun@refractions.net>. Improved and maintained by Sandro Santilli <strk@refractions.net>. Includes small contributions and improvements by others. This application uses functionality from shapelib 1.2.9 by Frank Warmerdam <warmerda@gdal.velocet.ca> to read from ESRI Shape files. SEE ALSO
pgsql2shp(1) More information is available at http://postgis.refractions.net shp2pgsql(1)
All times are GMT -4. The time now is 03:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy