Visit Our UNIX and Linux User Community


How to load comma seperated values file (*.csv) into Oracle table


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to load comma seperated values file (*.csv) into Oracle table
# 1  
Old 06-03-2002
Data How to load comma seperated values file (*.csv) into Oracle table

Hi all

I need to input values in a .csv file into my Oracle table running in Unix, I wonder what would be the command to do so...


The values are recorded in an excel file and I tried using a formatted text file to do so but failed because one of the field is simply too large to fit in the spreadsheet cell (the info in the cell is 300 char wide but an excel file only permits the cell to be 255 max), if I export the file in formatted text, this field cannot be exported.

Hence I am thinking of converting the excel file into a .csv and ftp to my Unix server and load it in, but I don't know the script to do that.

I am using a HP 9000 machine running HPUX.
# 2  
Old 06-04-2002
Quite important to know what version of interactive SQL you have set up on this box? I.e. mysql, isql etc..... These are database commands through an interactive sql language..so you'll need to tell us what type you use before we can help.
# 3  
Old 06-04-2002
Thanks for your reply, I'm using SQL Plus from Oracle

Thanks for your reply, I'm using SQL Plus from Oracle
# 4  
Old 06-04-2002
Okay - next question.... I assume that the table already exists.....correct?

And is the format of the data in the csv file the same as is required for the table.....i.e. is it char - or int...and does it match the table requirements for the fields?

Also - does every field in the file go directly into a field in the table....

i.e.

File:
a,b,c,d,e,f,g,h,i
a1,b1,c1,d1,e1,f1,g1,h1,i1

Table:
column1 (char(2)
column2 char(2)
...etc....

You will need to have the file data formatted into the same as the table..i.e. they may need speech marks around the values for char fields..... give me a bit more and there is a simpleish answer that I can show you if you answer these questions.
# 5  
Old 06-04-2002
Yup you are rite, the table is already there...

For the info in the csv file it's all char. and they do match requirements for the table

Also, every field goes directly into a field in the same sequence to a column in the table.

Instead of csv could I use a pipe | to seperate the fields? would that be easier?

Once again thanks a lot for your time and efforts
# 6  
Old 06-05-2002
Commas are fine for this..as you specify the delimiter.

It's quite a convoluted process.... but you use the sqlldr command.

Try and follow this link...it will explain it better than I could....

Let me know if this lets you do it okay.http://www.oakbrooktech.com/tutorial..._lesson_22.htm


Last edited by peter.herlihy; 06-05-2002 at 12:18 AM..
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #276
Difficulty: Easy
OpenSolaris was based on Solaris, which was originally released by Sun in 1999.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to load XML file to Oracle table

Experts. I have created a oracle table as below. create table xml_tab ( File_No number , File_content Varchar2(2000), file_type xmltype ); Daily we are receiving many XML files as below. here is our sample xml file. File1 : (7 Replies)
Discussion started by: vasuvv
7 Replies

2. Shell Programming and Scripting

Convert listner.log to csv format with comma seperated

Hi All, I am new to shell scripting i am trying to convert the listner.log to csv which can be inturn converted to excel for easy reading. i used this command awk '/SID=/ && /HOST=/ && /PORT=/ && /USER=/ { i=match($0,"SID="); i=i+RLENGTH; h0=substr($0,i); i=match(h0,")");... (6 Replies)
Discussion started by: skoshekay
6 Replies

3. UNIX for Dummies Questions & Answers

Handling Comma in string values in a CSV file

Hi have a comma separated file which has numeric and string columns. String columns are quoted and can have comma in between the quotes. How to identify the columns with FS ="," sample records"prabhat,kumar",19,2000,"bangalore,India" In awk it should be$1 = prabhat,kumar $2=19 $3=2000... (9 Replies)
Discussion started by: prabhat.diwaker
9 Replies

4. Shell Programming and Scripting

Update the table using values from a csv file

i want to run update query for oracle which is in up.sql taking values from a.csv. I have implemented shell script to do it. extn="perl" ls -1 | while read file do echo "$file,$extn" > a.csv done up.sql contains update file_list set filename=$1 where extn=$2; The code to update is... (2 Replies)
Discussion started by: millan
2 Replies

5. Shell Programming and Scripting

Convert comma seperated file to line seperated.

Hi, I have data like this. 1,2,3,4 Output required: 1 2 3 4 I am trying to use tr function but getting error. Help is appreciated. (6 Replies)
Discussion started by: pinnacle
6 Replies

6. Shell Programming and Scripting

Removing blank lines from comma seperated and space seperated file.

Hi, I want to remove empty/blank lines from comma seperated and space seperated files Thanks all for help (11 Replies)
Discussion started by: pinnacle
11 Replies

7. Shell Programming and Scripting

load a data from text file into a oracle table

Hi all, I have a data like, 0,R001,2,D this wants to be loaded into a oracle database table. Pl let me know how this has to be done. Thanks in advance (2 Replies)
Discussion started by: raji35
2 Replies

8. Shell Programming and Scripting

Comma Seperated List of Values

Hi, I have a comma seperated list of values: export list="red,blue,white,yellow" Given a value in a variable "look", i want to check whether the value is available in the above list. But the result should be based on exact string match and not part of the string. I am using following... (9 Replies)
Discussion started by: brap45
9 Replies

9. Shell Programming and Scripting

Handling .CSV( Comma seperated value) in awk

Hi Guys, I am trying to reading in comma seperated values in awk. I can set the delimiter to be a comma, but the tricky part is that commas that appear within quotes are not to be considered as delimiters. Could someone please help. Regards, Laud (1 Reply)
Discussion started by: Laud12345
1 Replies

10. UNIX for Advanced & Expert Users

How to load comma seperated values file (*.csv) into Oracle table

Hi all I need to input values in a .csv file into my Oracle table running in Unix, I wonder what would be the command to do so... The values are recorded in an excel file and I tried using a formatted text file to do so but failed because one of the field is simply too large to fit in the... (4 Replies)
Discussion started by: handynas
4 Replies

Featured Tech Videos