Data Warehousing Community Forum Data Warehousing Community Forum
The Warehouse of Data warehousing knowledge ...
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 06, 2010, 02:04:13 am


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: Processing a .CSV file to Table  (Read 664 times)
Sipra
Founder
*****

Reputation: +35/-0
Offline Offline

Posts: 238


I am the King...


View Profile WWW
« on: July 03, 2008, 11:34:03 am »

HI Friends,

Please le tme know how to process a .CSV file to Table by using SQL loader Concept.

No other technique required...! Know it can be done thru various processes. But need to acquire this in the above way...
 Grin
Logged

unknown
DW Apprentice
**

Reputation: +7/-0
Offline Offline

Posts: 44



View Profile
« Reply #1 on: July 04, 2008, 03:20:00 pm »

SQL Loader is a bulk loader utility used for moving data from external files (.CSV, .txt, .dat, excel, .xml, etc.,)  into the Oracle database. SQL Loader supports various load formats, selective loading, and multi-table loads.

Look at the following example -

Have to be executed at the command prompt  -
            sqlldr username@server/password control=loader.ctl

Before executing this, you have to prepare a control file which is mentioned in the above command line (eg - loader.ctl)
This sample control file (loader.ctl) will load an external data file containing delimited data -
loader.ctl contents -
 
        load data
        infile 'c:\data\mydata.csv'
        into table emp
        fields terminated by "," optionally enclosed by "'"       
        (empno,
        empname,
        sal,
        deptno
        hiredate date "ddmonyyyy"
        )


This will automatically creates a log file and a bad file which will have the log details and rejected data respectively.

The above one is an example of simple SQL loader for delimited .csv file.
Logged

Thanks
Unknown Smiley
Sipra
Founder
*****

Reputation: +35/-0
Offline Offline

Posts: 238


I am the King...


View Profile WWW
« Reply #2 on: July 15, 2008, 06:00:19 pm »


        fields terminated by "," optionally enclosed by "'"       
Finally, it worked with some other options -

        fields terminated by "," optionally enclosed by ""/"   
        fields terminated by "," optionally enclosed by "\"" trailing nullcols    
       

as all the varchar/date fields in the .csv files are quoted with double quotes.
And also by increasing the error count to some maximun satisfied value.
« Last Edit: December 11, 2008, 03:46:34 pm by Sipra » Logged

ecearundeva
DW Fresher
*

Reputation: +1/-0
Offline Offline

Posts: 1


View Profile
« Reply #3 on: March 24, 2009, 02:22:17 pm »

Hi,

To check which options are available in any release of SQL*Loader use this command:
sqlldr help=y

From the above post(Posted by: unknown)
He/She mentioned that   
Control file to load data:

Quote
load data
        infile 'c:\data\mydata.csv'
        into table emp
        fields terminated by "," optionally enclosed by "'"       
        (empno,
        empname,
        sal,
        deptno
        hiredate date "ddmonyyyy"
        )


This will automatically creates a log file and a bad file which will have the log details and rejected data respectively.

Yes by typing this " sqlldr username@server/password control=loader.ctl" on the command prompt, log file file will get generated.
But to get bad file , you need to include
BADFILE 'c:\temp\filename.bad' in the control file.

You can learn much more from here
Quote

Admin - retouched as per the rules
« Last Edit: March 28, 2009, 09:38:49 pm by Sipra » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  



© Copyright 2006-2010 DW Forum. All rights reserved

contactSanghala | Cyber Militia | Powered by SMF | SMF © 2006-2009, Simple Machines LLC | Dilber MC Theme by HarzeM