Populating table from csv
Hi all .. i need the syntax for populating a table from hard drive stored csv file. there are 6 fields in target table (named orgs) and i want to populate its fields 'in' and 'out' from csv file. can someone plz help me? for the time being i m doing it manually by creating scripts in excell sheet but thats not a good approach. i m using oracle 9i. thanx in advance
Hi,
Take this example:
I made a directory 'scott_dir' in my drive & put my csv file in it.
Then i created an external table using the following:
create table emp_ext (
EMPNO NUMBER(4),
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2))
Organization external
(type oracle_loader
default directory scott_dir
access parameters (records delimited by newline
fields terminated by ',')
location ('emp_ext.csv'))
reject limit 1000;
It will insert data from your csv file to the emp_ext table.
You can verify data using the Select statement.
Later on you can merge data in your original table.
Thanks
Similar Messages
-
Bulk Insert into a Table from CSV file
I have a CSV file with 1000 records and i have to insert those records into a table.
I tried for Bulk Insert command and Load data infile command but it throws error.
Am using Oracle 10g Express Edition.
I want to achieve it thru query command and not by plsql procedures
Please send me query syntax for this problem. . . .
Thanks in Advance,
Hariharan ST.Hi
If you create an external table that points to your csv file you will then be able populate your table from a query.
See: http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11210
Hope this helps -
Populating table from excel or other source
What is the easiest way to populate a table from an existing Word or Excel file? I am looking at a long list with name, address, phone, website fields and would like to avoid dragging and dropping or hand entering. Should the file be saved as a comma or tab separated ascii? Can someone point me in the right direction?
Thanks,
JoeHi Joe,
in addition to Mylenium's hint I want to show you this alternative Adobe-option, look here:
http://help.adobe.com/en_US/dreamweaver/cs/using/WSc78c5058ca073340dcda9110b1f693f21-7ce6a .html
In it finds this small restriction: Note: If you use Microsoft Office 97, you cannot import the contents of a Word or Excel document; you must insert a link to the document.
Hans-G. -
How to update Records of SAP table from .CSV file
Hi,
I have written a code which takes a data from (,) delimited CSV file and adds it into the Internal table.
Now I want to update the all fields in SAP table with the Internal table.
I want to use Update statement.
Update <table Name> SET <field needs to update> WHERE connditon.
I don't want to iterate through thousand on record in sap table to check the where condition.
Could you please tell me how to do it.Hi. I thing you will not workaround the iterating of the internal table.
You can pre-load all the records into another internal table
check lt_csv[] is not initial. " important, otherwise next select would read all records of the table
select .... into lt_dbitab for all entries in lt_csv where key-fieds = lt_csv-key_fields...
check sy-subrc eq 0 and lt_dbitab[] is not initial.
then do in-memory update of the it_dbitab
loop at it_dbitab assign <fs>.
read table lt_csv assign <fs_csv> with key ... " lt_csv should be sorted table with key, or you should try to use binary search
if sy-subrc eq 0.
...change required lt_dbitab fields: <fs>-comp = <fs_csv>-comp...
endif.
endloop.
ant then you can do mass-update
update dbtab from table lt_dbitab.
From performance view, this solution should be much faster than iterating lt_csv directly and updating every single database record
Br
Bohuslav -
Populating table from database
Number FoodItem Quantity Price Description
1 Rice 1 bag 5000 Carbohydrate
2 Beans 1 bag 4000 Protein
3 Palm Oil 1 bottle 500 Fats & Oil
i have a table like this in my database,need help in populating my list
with "FoodItem" from the database when my GUI comes up.Also,want to display final result of selection in my table.
'\n'
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import static javax.swing.GroupLayout.Alignment.*;
import java.sql.*;
import java.util.*;
public class Foodtable extends JFrame {
//private JButton finish,view;
private JTable table;
private DefaultTableModel model;
private JScrollPane pane,pane1;
private JTextField currentamount,totalamount,qtyfield;
private JList foodlist;
private JComboBox box;
private String[] qtybox={"cup","mudu","bag"};
private DefaultListModel lm;
Connection con=null;
Statement st=null;
private static ResultSet rs;
public Foodtable(){
JPanel p1 = new JPanel();
p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Food List",TitledBorder.CENTER,TitledBorder.TOP));
p1.setLayout(null);
p1.setPreferredSize(new Dimension(170,150));
lm = new DefaultListModel();
foodlist = new JList(lm);
pane1 = new JScrollPane(foodlist);
pane1.setBounds(10,20,148,180);
p1.add(pane1);
JLabel qty = new JLabel("Quantity:");
qty.setBounds(10,210,60,20);
p1.add(qty);
qtyfield = new JTextField(5);
qtyfield.setBounds(65,210,30,20);
p1.add(qtyfield);
box = new JComboBox(qtybox);
box.setBounds(95,210,60,20);
p1.add(box);
JPanel p2 = new JPanel();
p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Food Table",TitledBorder.CENTER,TitledBorder.TOP));
model = new DefaultTableModel();
model.addColumn("Number");
model.addColumn("Food Item");
model.addColumn("Quantity");
model.addColumn("Price");
model.addColumn("Description");
table = new JTable(model);
pane = new JScrollPane(table);
pane.setPreferredSize(new Dimension(300,140));
p2.add(pane);
JPanel p = new JPanel();
GroupLayout layout = new GroupLayout(p);
p.setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(p1)
.addComponent(p2)
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(p1)
.addComponent(p2)
JPanel p4 = new JPanel();
p4.setLayout(null);
p4.setPreferredSize(new Dimension(200,30));
/*finish = new JButton("Finish");
finish.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
finish.setRolloverEnabled(false);
finish.setBounds(170,20,60,20);
p4.add(finish);*/
JLabel currentlabel = new JLabel("Current Amount:");
currentlabel.setBounds(300,10,100,20);
p4.add(currentlabel);
currentamount = new JTextField();
currentamount.setBounds(395,10,50,20);
currentamount.setEditable(false);
p4.add(currentamount);
JLabel total = new JLabel("Amount Spent:");
total.setBounds(300,30,100,20);
p4.add(total);
totalamount = new JTextField();
totalamount.setBounds(395,30,50,20);
totalamount.setEditable(false);
p4.add(totalamount);
GroupLayout flayout = new GroupLayout(getContentPane());
getContentPane().setLayout(flayout);
flayout.setAutoCreateGaps(true);
flayout.setAutoCreateContainerGaps(true);
flayout.setHorizontalGroup(flayout.createSequentialGroup()
.addGroup(flayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(p)
.addComponent(p4)
flayout.setVerticalGroup(flayout.createSequentialGroup()
.addGroup(flayout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(flayout.createSequentialGroup()
.addGroup(flayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(p)
.addComponent(p4)
setSize(640,460);
setDefaultCloseOperation(EXIT_ON_CLOSE);
public static void main(String[] arg){
new Foodtable().setVisible(true);
public void showRecord(){
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:food","","");
st = con.createStatement();
rs=st.executeQuery("SELECT*FROM tbl_food");
while(rs.next()){
lm.addElement(rs.getString("food_name"));
catch(Exception sqle){
JOptionPane.showMessageDialog(null,"Exception.......\n" + sqle.getMessage() ,"Error Information",JOptionPane.ERROR_MESSAGE);
/*public void query(){
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/food?user=password=");
st = con.createStatement();
String sql = "SELECT foodlist.food,foodlist.description FROM foodlist";
rs = st.executeQuery(sql);
while(rs.next()){
lm.addElement(rs.getString(1)+'\n');
}catch(Exception ee){
System.out.println(ee);
finally{
try{
st.close();
con.close();
}catch(Exception ex){ System.err.println(ex);}
public void actionPerformed(ActionEvent e){
Object[] value = foodlist.getSelectedValues();
if(e.getSource()==view){
query();
if(e.getSource() == move){
for(int i=0;i<value.length;i++){
String word = (String)value;
//String foodclass = rs.getString("foodlist.description");
Vector<Object> data = new Vector<Object>();
data.addElement(word);
data.addElement(qtyfield.getText()+" "+box.getSelectedItem());
data.addElement("");
//data.addElement("foodclass");
model.addRow(data);This particular forum is about jdbc. Do you have a question about jdbc?
If so then what specifically is it?
If you have questions about GUIs (display, buttons, events, etc) then there are other forums for that. -
Error while creating table from csv file
I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
Any idea?I am getting an error while creating a table using 'Import Data' button for a csv file containing 22 columns and 8 rows. For primary key, I am using an existing column 'Line' and 'Not generated' options.
ORA-20001: Excel load run ddl error: drop table "RESTORE" ORA-00942: table or view does not exist ORA-20001: Excel load run ddl error: create table "RESTORE" ( "LINE" NUMBER, "PHASE" VARCHAR2(30), "RDC_MEDIA_ID" VARCHAR2(30), "CLIENT_MEDIA_LABEL" VARCHAR2(30), "MEDIA_TYPE" VARCHAR2(30), "SIZE_GB" NUMBER, "RDC_IMG_HD_A" NUMBER, "START_TECH" VARCHAR2(30), "CREATE_DATE" VARCHAR2(30), "RDC_MEDIA_DEST" VARCHAR2(30), "POD" NUMBER, "TAPE" NUMBER, "ERRORS_YN" VA
Any idea? -
I have data in a CSV(comma separated values) file and would like to create a table for each row in that file in iBooks. Is there an easier way of doing it other than manually copying and pasting the values for each row in a table in iBooks Author?
Each row has 4 values so each table would be a 2x4 table. There are about 500 rows.
Thanks.Thanks for your quick reply.
I tried laying them out in word and doing the insert like you said. I think that works ok. However formatting is still an issue. Need to look into that.
Is there a way to insert audio or hyperlinks in a Table cell in iBooks author? I tried but it wasnt letting me do that. -
Loading data from .csv file into Oracle Table
Hi,
I have a requirement where I need to populate data from .csv file into oracle table.
Is there any mechanism so that i can follow the same?
Any help will be fruitful.
Thanks and regardsYou can use Sql Loader or External tables for your requirement
Missed Karthick's post ...alredy there :)
Edited by: Rajneesh Kumar on Dec 4, 2008 10:54 AM -
Loading data from .csv file into existing table
Hi,
I have taken a look at several threads which talk about loading data from .csv file into existing /new table. Also checked out Vikas's application regarding the same. I am trying to explain my requirement with an example.
I have a .csv file and I want the data to be loaded into an existing table. The timesheet table columns are -
timesheet_entry_id,time_worked,timesheet_date,project_key .
The csv columns are :
project,utilization,project_key,timesheet_category,employee,timesheet_date , hours_worked etc.
What I needed to know is that before the csv data is loaded into the timesheet table is there any way of validating the project key ( which is the primary key of the projects table) with the projects table . I need to perform similar validations with other columns like customer_id from customers table. Basically the loading should be done after validating if the data exists in the parent table. Has anyone done this kind of loading through the APEX utility-data load.Or is there another method of accomplishing the same.
Does Vikas's application do what the utility does ( i am assuming that the code being from 2005 the utility was not incorporated in APEX at that time). Any helpful advise is greatly appreciated.
Thanks,
AnjaliHi Anjali,
Take a look at these threads which might outline different ways to do it -
File Browse, File Upload
Loading CSV file using external table
Loading a CSV file into a table
you can create hidden items in the page to validate previous records before insert data.
Hope this helps,
M Tajuddin
http://tajuddin.whitepagesbd.com -
Loading records from .csv file to SAP table via SAP Program
Hi,
I have a .csv file with 132,869 records and I am trying to load it to an SAP table with a customized SAP program.
After executing the program, only 99,999 records are being loaded into the table.
Is there some setting to define how many records can be loaded into a table? Or what else could be the problem?
Pls advice.
Thanks!!!hi Arun ,
A datasource need a extract structure to fetch data .It is nothing but a temp table to hold data.
First you need to create atable in SE11 with fields coming from CSV file.
Then you need to write a report program to read you CSV file and populate your table in BW .
Then you can create a datasource on top of this table .
After that replicate and load data at PSA and use to upper flow.
Regards,
Jaya Tiwari -
How to load the data from .csv file to oracle table???
Hi,
I am using oracle 10g , plsql developer. Can anyone help me in how to load the data from .csv file to oracle table. The table is already created with the required columns. The .csv file is having about 10lakh records. Is it possible to load 10lakh records. can any one please tell me how to proceed.
Thanks in advance981145 wrote:
Can you tell more about sql * loader??? how to know that utility is available for me or not??? I am using oracle 10g database and plsql developer???SQL*Loader is part of the Oracle client. If you have a developer installation you should normally have it on your client.
the command is
sqlldrType it and see if you have it installed.
Have a look also at the FAQ link posted by Marwin.
There are plenty of examples also on the web.
Regards.
Al -
Data Migration from CSV file to Database Table.
Hi,
I have checked few answered threads on Data Migration Issues but didn't find the solution yet.
I am reading data from an CSV file to internal table but the complete row is coming under one field of the internal table.
How i can get values in different fields of the internal table from the CSV file ?
Thanks & Regards.
Raman Khurana.Hi,
If you are using GUI_UPLOAD, you might have missed to make has_field_separator as 'X'.
EXPORTING
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\File.csv'
filetype = 'ASC'
has_field_separator = ' X' "<= Set this as 'X'.
TABLES
data_tab = itab.
Regards,
Manoj Kumar P -
SQL loaded not loading data from csv format to oracle table.
Hi,
I trying to load data from flat files to oracle table,it not loading decimal values.Only character type of data is loaded and number format is null.
CONTROL FILE:
LOAD DATA
INFILE cost.csv
BADFILE consolidate.bad
DISCARDFILE Sybase_inventory.dis
INSERT
INTO TABLE FIT_UNIX_NT_SERVER_COSTS
FIELDS TERMINATED BY ',' optionally enclosed by '"'
TRAILING NULLCOLS
HOST_NM,
SERVICE_9071_DOLLAR FLOAT,
SERVICE_9310_DOLLAR FLOAT,
SERVICE_9700_DOLLAR FLOAT,
SERVICE_9701_DOLLAR FLOAT,
SERVICE_9710_DOLLAR FLOAT,
SERVICE_9711_DOLLAR FLOAT,
SERVICE_9712_DOLLAR FLOAT,
SERVICE_9713_DOLLAR FLOAT,
SERVICE_9720_DOLLAR FLOAT,
SERVICE_9721_DOLLAR FLOAT,
SERVICE_9730_DOLLAR FLOAT,
SERVICE_9731_DOLLAR FLOAT,
SERVICE_9750_DOLLAR FLOAT,
SERVICE_9751_DOLLAR FLOAT,
GRAND_TOTAL FLOAT
In table FLOAT are replaced by number(20,20)
SAmple i/p from csv:
ABOS12,122.46,,1315.00,,1400.00,,,,,,,,1855.62,,4693.07
Only abos12 is loaded and rest of the number are not loaded.
Thanks.Hi,
Thanks for your reply.
Its throwing error.
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table FIT_UNIX_NT_SERVER_COSTS, loaded from every logical record.
Insert option in effect for this table: INSERT
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
HOST_NM FIRST 255 , O(") CHARACTER
SERVICE_9071_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9310_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9700_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9701_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9710_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9711_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9712_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9713_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9720_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9721_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9730_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9731_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9750_DOLLAR NEXT 255 , O(") CHARACTER
SERVICE_9751_DOLLAR NEXT 255 , O(") CHARACTER
GRAND_TOTAL NEXT 255 , O(") CHARACTER
value used for ROWS parameter changed from 64 to 62
Record 1: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 2: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 3: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 4: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 5: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 6: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 7: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 8: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 9: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 10: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Record 11: Rejected - Error on table FIT_UNIX_NT_SERVER_COSTS, column GRAND_TOTAL.
ORA-01722: invalid number
Please help me on it.
Thanks, -
SQL* Loader Loading specific column from CSV file to the table
Dear All,
Iam Loading specific column from .CSV file to the oracle table.
Could pls help how i can load only that cols into the table
Eg: CSV file having id, Frst_name,Last_name, Address,Phone,Insurance etc
out of this I want to load only Frst_name,Last_name columns to oracle table say fname and lname.
Thanks in Adv.
JunuLily,
I made some changes to your table def but you will get the idea
-- Table EMPLOYEE
CREATE TABLE EMPLOYEE
EMPID NUMBER NOT NULL,
EMPNICKNAME VARCHAR2(10 BYTE) NULL,
FNAME VARCHAR2(20 BYTE) NOT NULL,
MI VARCHAR2(20 BYTE) NULL,
LNAME VARCHAR2(20 BYTE) NOT NULL,
FULLNAME VARCHAR2(20 BYTE) NOT NULL,
HIREDATE DATE DEFAULT SYSDATE NOT NULL
-- data file employee.dat
1,amy,b,amy b
2,cindy,d,cindy d
3,eric,f,eric f
4,gary,h,gary
-- Control file : Employee.ctl ( you can use truncate, replace or append , see sqlldr for more options)
load data
Truncate into table employee
fields terminated by ","
optionally enclosed by '"'
TRAILING NULLCOLS
empId INTEGER EXTERNAL,
FName char(20),
LName char(20),
FullName char(30)
now to load use following or you can speicify infile in control fle
sqlldr username/passowrd control=employee.ctl data=employee.dat log=employee.log
{code}
Hope this help.
Regards -
How to Move from CSV to Table in Physical layer in Best possible way
We had a project which had the source (physical Layer) as CSV. Now there are moving from CSV to a Table in the Database.
Can anyone guide through the best possible way to complete the task
With Regards!
SteveCreate a new Database node in the Physical layer with connection pool, create a schema folder and drag your CSV object into the new database - All your BMM mappings and hence Presentation objects will move over seamlessly.
Might be an idea to simply reverse engineer / import any object from your database to initially create your database connection / tree then simply drag the CSV into it.
Hope this helps,
Alastair
Maybe you are looking for
-
i got an iphone4 as a gift from the UK but not working here in Nigeria. i need to know if i can unlock it online?
-
Error during the creation of transport request
Hi After collection of the objects in transport connection and clicking on the truck icon. the follwing msg is being displayed and cannot more furthur with all objects. Edit objects separately since they belong to different original systems after cli
-
MDG BP(role=Customer) vs MDG Customer
Hi All, As I understand,using the Supplier MDG,it can create a BP either as a Vendor or a Customer depending on the Supplier role chosen. When EHP6 MDG comes with a Customer object,what will be the overlap between MDG-Supplier(role=Customer
-
Oracle VM 3.03 Kickstart
I can get my server to boot the PXE and I can manually answer all the prompts and install OVM 3.0.3 on my server but for the life of me.... I can't call a kickstart script. Here is my append statement on the PXE server. label 1 kernel server/mboot.c3
-
I have a mac book pro but I'm sing some keys from the keyboard
How can't I get my Keyboard replace?