Loading Data From a Text File Through an Application into Oracle
Hi There,
I have a web application that allows the user to upload a text file. This file is then processed by my application. Each line in the file is a new row I need to insert into my table.
Currently, I batch 200 updates together and insert them into the DB.
For about 3 million records this is taking much longer than I would like it to.
Any suggestions for optimization?
thanks.
I put here a simplest demo (file has whitespace)
I think it may help to start.
--Structure of your file test1.dat (put in your directory)
a1 b1
a2 b2
a3 b3
a4 b4
CREATE OR REPLACE DIRECTORY
test_dir AS
'C:\oraclexe\DIR' --or anywhere
--GRANT READ, WRITE ON DIRECTORY test_dir TO your_user
--external table:
DROP TABLE test_ext
CREATE TABLE test_ext
(col1 CHAR(5),
col2 CHAR(5)
ORGANIZATION EXTERNAL
(TYPE oracle_loader
DEFAULT DIRECTORY test_dir
ACCESS PARAMETERS
(RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY WHITESPACE)
LOCATION ('test1.dat')
SELECT * FROM test_ext
COL1 COL2
a1 b1
a2 b2
a3 b3
a4 b4
Insert into another_table(another_col1, another_col2) (select col1, col2 from test_ext) if needed
Similar Messages
-
Error while loading data from a text file to a datastore
Hi all,
i am a starter in ODI. I am trying to load data from a text file into a datastore. I have put the file on a unix server whose location is defined in the topology manager. when i am trying to "view data" it is giving me error file does not exist at <location where i have put the file>. Please help meHi,
1. If your files are on a remote File System, you will need to copy one of your files to the machine ODI Designer is running on to allow ODI to retrieve the metadata information of the file.
2. In Topology create a Physical Schema, the directory you enter for Data and Work Schema should point at this local file.
3. Then define the File Datastore in ODI Designer. Enter a name, browse and select the file and fill in each filed of the Files tab.
* If its a Fixed file, click on the grid icon on the Columns tab to enter the columns and have Automatic Adjustment checked.
* If its a Delimited file, use the Reverse button on the Columns tab to reverse the columns.
* Right click on the File Datastore select View Data, if you can view data, that means the File Datastore has been defined correctly.
* If not, check each tab of the File Datastore to make sure everything is defined correctly and retry.
4. Once View Data is successful, you now change the directories (Data and Work Schema in Topology) to point at the remote File System. These directories must be accessible to the ODI Agent that will be used to run the transformations. The directory can be an absolute path (m:/public/data/files) or relative to the ODI Agent startup directory (../demo/files). It is strongly advised to use a UNC (independent from the execution location) for the path. When running the transformations with "no agent", the directory is relative to the directory where Oracle Data Integrator has been installed.
You need to have a agent process running at the system where your source file resides .
Then while running the odi interface choose that agent .
Thanks,
Sutirtha -
Need help in loading data from a csv file to a table in Oracle DB
Hi,
I am using sqlplus as a client to connect to the server.
I am trying to load data from a csv file from a client to a table in Oracle DB server.
I am trying to use the below command
" LOAD DATA INFILE 'test.csv' INTO TABLE testTable FIELDS TERMINATED BY ',' (test1,test2,testc3,testc4); "
But, I am encountered with the following error
"SP2-0042: unknown command "load data" - rest of line ignored."
Thanks in advance.
SBHey Frostmann,
That was a nice post....
I changed my mind to use an 'Insert into' statement from a shell script.
I created a DB table named test and I tried using the below shell script to insert a row in the table.
sqlplus test/test@test <<ENDOFSQL
INSERT INTO test VALUES('test1',123,'test2','test3');
exit
ENDOFSQL
A row is succesfully inserted into the table when I run the script manually, but it does not insert rows when a cron job is scheduled.
Could you please help me with this?
Thanks in advance.
SB -
How to automate loading data from a text file ?
Hi,
I need to load a data form a text file automatically. (for example: every day at 6.p.m) .
It is possible to use DBMS_SCHEDULER with SQL LOADER ? or maybe u have others idea ?
regards,assuming that the text file resides at the machine where the database is installed at you can create a procedure that use the built-in UTL_FILE package to read and load the data to the oracle tables. then create a job that use the DBMS_JOB or DBMS_SCHEDULER to create an automated schedule to run the job that calls the procedure you have created.
or assuming that the text file resides or at the local/client machine (example c:\ drive) on a windows xp platform. create a batch file that do a ftp to transfer the text file to the oracle database server and create a schedule job using the windows scheduler. also create a procedure that use the built-in UTL_FILE package to read and load the data to the oracle tables. then create a job that use the DBMS_JOB or DBMS_SCHEDULER to create an automated schedule to run the job that calls the procedure you have created. -
How to import data from a text file through DTS to Sql Server
Please don't mistake me as i'm a new comer to sql server,please help me.
how to import the data present in a plain text file through DTS into sql server and store the data in a temporary table.
How far the temporary table is stored in the database.
Please reply me as soon as possible.
Thank you viewers.>
I can say that anybody with
no experience could easily do an export/import in
MSSQLServer 2000.
Anybody with no experience should not mess up my Oracle Databases ! -
I have a text file in a data archive that contains various information (numeric and string) that I need to load into different controls in a VI would I have to open the file and look for certain characters to begin and end loading? The information was previously stored by the VI from the control so can I simply load a previous set of data by using it's data path and control file name?
Solved!
Go to Solution.I assume that the numbers following the "OH data is listed below:" is supposed to go into a 2D array?
There are several ways to do this. One simple way is to simply read the file and chop off each section of interest, and converting the string to a 2D array, like this:
Another is to read the file in using the Read From Spreadsheet File, and then indexing out the first column, and use that to search for the indices where the regions of interest lie. You can then use Array Subset to get the 2D array of data.
Message Edited by smercurio_fc on 07-22-2009 02:56 PM
Attachments:
Example_VI.png 15 KB -
Is there away to load data from a text file to a table?
I have data stored in filename.txt and I want to load those data into a table on the front pannel of vi. How can I do that?
Se;
If the text file is already in an spreadsheet format, you can download the VI Read Strings From Spreadsheet File from my website:
http://www.jyestudio.com/lview.shtml
It is the suggested modification of the VI Read From Spreadsheet File that comes with LabVIEW, as stated in the diagram.
If the text file is not in spreadsheet format, then you need to write your own code to make the string table suitable for the table.
Regards;
Enrique
www.vartortech.com -
PROBLEM LOADING DATA FROM A TEXT FILE.
Hi,
Im having a problem in loading my csv file to the database. Im using Oracle Database 10g for Linux. Im in p. 228 in the book. This is my csv file look.
db_name db_version host_id
db10 9.2.0.7 1
db11 10.2.0.1 1
db12 10.2.0.1 1
db13 9.2.0.7 1
db14 10.2.0.1 1
db15 9.2.0.7 1
I loaded this data to an existing table called DATABASES loaded from tab delimited. FILE CHARACTER SET is UNICODE UTF-8. Then I browsed the name of the csv file to be uploaded. It looked like this.
File Name F23757437/db2.csv Reupload File
Separator
Optionally Enclosed By
First row contains column names.
File Character Set
I CLICKED NEXT, THIS IS WHAT IT LOOKED LIKE.
Schema: HANDSONXE06
Table Name: DATABASES
Define Column Mapping
Column Names %
Format
Upload yes
Row 1 "db10" "9.2.0.7" 1
Row 2 "db11" "10.2.0.1" 1
Row 3 "db12" "10.2.0.1" 1
Row 4 "db13" "9.2.0.7" 1
Row 5 "db14" "10.2.0.1" 1
Row 6 "db15" "9.2.0.7" 1
I CLICKED LOAD AND THIS WAS THE RESULT.
* There are NOT NULL columns in HANDSONXE06.DATABASES. Select to upload the data without an error.
Schema
Down
Table Name
Down
File Details
Down
Column Mapping
Load Data
Schema: HANDSONXE06
Table Name: DATABASES
Define Column Mapping
Column Names COLUMN_NAMES
Format FORMAT
Upload UPLOAD
Row 1 "db10" "9.2.0.7" 1
Row 2 "db11" "10.2.0.1" 1
Row 3 "db12" "10.2.0.1" 1
Row 4 "db13" "9.2.0.7" 1
Row 5 "db14" "10.2.0.1" 1
Row 6 "db15" "9.2.0.7" 1
I WAS REALLY WONDERING WHAT WAS REALLY WRONG. AN ERROR MESSAGE SAID, THERE ARE NOT NULL COLUMNS IN THE HANDSONXE06.DATABASES. I DIDN'T KNOW HOW TO FIX IT. WHAT DO I NEED TO CHANGE TO LOAD THE DATA WITHOUT AN ERROR? IT REALLY CONFUSED ME A LOT AND HOW COME I HAVE AN ERROR? PLEASE HELP ME. I NEED AND ANSWER TO MY PROBLEM PLEASE. I CANNOT GO FORWARD BECAUSE OF THIS.
THANKS,
JOCELYNI'm not certain of the utility you are using to load the data, however, I completed the following test using SQL Loader to insert the data into my table. Your process should work similar if the trigger and sequence are created for the table you are loading.
SQL> create table load_tbl
2 (db_id number(3) not null,
3 db_name varchar2(100) not null,
4 db_version varchar2(25),
5 host_id number(3) not null)
6 /
Table created.
SQL> desc load_tbl
Name Null? Type
DB_ID NOT NULL NUMBER(3)
DB_NAME NOT NULL VARCHAR2(100)
DB_VERSION VARCHAR2(25)
HOST_ID NOT NULL NUMBER(3)
SQL> create sequence db_id_seq;
Sequence created.
SQL> create or replace trigger db_id_trig
2 before insert on load_tbl
3 for each row
4 when (new.db_id is null)
5 begin
6 select db_id_seq.nextval into :new.db_id from dual;
7 end;
8 /
Trigger created.
The contents of the data file, control file and log file are below for the load into load_tbl.
C:\>sqlldr userid=username/password@db control=db_id_load.ctl log=db_id_load.log
SQL*Loader: Release 9.2.0.6.0 - Production on Thu Jan 18 17:21:47 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Commit point reached - logical record count 6
C:\>
SQL> select * from load_tbl
2 /
DB_ID DB_NAME DB_VERSION HOST_ID
1 db10 9.2.0.7 1
2 db11 10.2.0.1 1
3 db12 10.2.0.1 1
4 db13 9.2.0.7 1
5 db14 10.2.0.1 1
6 db15 9.2.0.7 1
6 rows selected.
SQL>
Data File"db10" "9.2.0.7" 1
"db11" "10.2.0.1" 1
"db12" "10.2.0.1" 1
"db13" "9.2.0.7" 1
"db14" "10.2.0.1" 1
"db15" "9.2.0.7" 1
Control FileLOAD DATA
INFILE "C:\db_id_load.dat"
APPEND INTO TABLE load_tbl
FIELDS TERMINATED BY WHITESPACE OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(db_name CHAR,
db_version CHAR,
host_id "TO_NUMBER(:host_id,'99999999999')"
Log FileSQL*Loader: Release 9.2.0.6.0 - Production on Thu Jan 18 17:21:47 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Control File: db_id_load.ctl
Data File: C:\db_id_load.dat
Bad File: db_id_load.bad
Discard File: none specified
(Allow all discards)
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 LOAD_TBL, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
DB_NAME FIRST * WHT O(") CHARACTER
DB_VERSION NEXT * WHT O(") CHARACTER
HOST_ID NEXT * WHT O(") CHARACTER
SQL string for column : "TO_NUMBER(:host_id,'99999999999')"
Table LOAD_TBL:
6 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 49536 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 6
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Thu Jan 18 17:21:47 2007
Run ended on Thu Jan 18 17:21:47 2007
Elapsed time was: 00:00:00.39
CPU time was: 00:00:00.13 -
How to do import data from the text file into the mathscript window?
Could anyone tell me how to do import data from text file into mathscript window for labview 8?
MathScript Window openned, File, Load Data - it has options: custom pattern (*.mlv) or all files.
ThanksHi Milan,
Prior to loading data in Mathscript Window , you have to save the data from the Mathscript window (the default extension of the file is .mlv but you can choose any extension). This means that you cannot load data from a text file that was not created using the Mathscript window.
Please let me know if you have any further questions regarding this issue.
Regards,
Ankita -
How do you read data from a text file into a JTextArea?
I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?
Student_Coder wrote:
1) Read the file messages.txt into a String
2) Initialize messages with the String as the textSwing text components are designed to use Unix-style linefeeds (\n) as line separators. If the text file happens to use a different style, like DOS's carriage-return+linefeed (\r\n), it needs to be converted. The read() method does that, and it saves the info about the line separator style in the Document so the write() method can re-convert it.
lethalwire wrote:
They have 2 different ways of importing documents in this link:
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
Neither of those methods applies to JTextAreas. -
Adding data from a text file into a JTextArea
I'm working on a blogging program and I need to add data from a text file named messages.txt into a JTextArea named messages. How do I go about doing this?
then you need to be more specific in what you need help with because those are two commonly used options for reading data in from a file. what have you tried? where is your code failing? what kind of errors are you getting? of course it looks like others in the forum have already reprimanded you for failing to post properly.
i have used both FileReader and the nio package for cfg and ini files which are both just txt files as well as massive data files. so tell me how they dont help you? -
How to load Test data from a Text file in ECATT
Hi,
I have created a test configuration with a test script, system data container, and test data container.
I have done the recording of a transaction and created the script. Parameterization is done for the script and have imported those parameters from script in to the data container.
I am trying to load a the data from a text file on the local work-station. The data is not being read.
Please explain this in detail (step by step) as I am very new to ECATT.
I am trying this on SAP ECC 6.0 IDES server.
Thanks in Advance
Vikas PatilPlease explain this in detail (step by step) as I am very new to ECATT.
Thanks in Advance
Vikas Patil -
How to import data from a text file into a table
Hello,
I need help with importing data from a .csv file with comma delimiter into a table.
I've been struggling to figure out how to use the "Import from Files" wizard in Oracle 10g web-base Enterprise Manager.
I have not been able to find a simple instruction on how to use the Wizard.
I have looked at the Oracle Database Utilities - Overview of Oracle Data Pump and the Help on the "Import: Files" page.
Neither one gave me enough instruction to be able to do the import successfully.
Using the "Import from file" wizard, I created a Directory Object using the Create Directory Object button. I Copied the file from which i needed to import the data into the Operating System Directory i had defined in the Create Directory Object page. I chose "Entire files" for the Import type.
Step 1 of 4 is the "Import:Re-Mapping" page, I have no idea what i need to do on this page. All i know i am not tying to import data that was in one schema into a different schema and I am not importing data that was in one tablespace into a different tablespace and i am not R-Mapping datafiles either. I am importing data from a csv file.
For step 2 of 4, "Import:Options" page, I selected the same directory object i had created.
For step 3 of 4, I entered a job name and a description and selected Start Immediately option.
What i noticed going through the wizard, the wizard never asked into which table do i want to import the data.
I submitted the job and I got ORA-31619 invalid dump file error.
I was sure that the wizard was going to fail when it never asked me into which table do i want to import the data.
I tried to use the "imp" utility in command-line window.
After I entered (imp), i was prompted for the username and the password and then the buffer size as soon as i entered the min buffer size I got the following error and the import was terminated:
C:\>imp
Import: Release 10.1.0.2.0 - Production on Fri Jul 9 12:56:11 2004
Copyright (c) 1982, 2004, Oracle. All rights reserved.
Username: user1
Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
tion
With the Partitioning, OLAP and Data Mining options
Import file: EXPDAT.DMP > c:\securParms\securParms.csv
Enter insert buffer size (minimum is 8192) 30720> 8192
IMP-00037: Character set marker unknown
IMP-00000: Import terminated unsuccessfully
Please show me the easiest way to import a text file into a table. How complex could it be to do a simple import into a table using a text file?
We are testing our application against both an Oracle database and a MSSQLServer 2000 database.
I was able to import the data into a table in MSSQLServer database and I can say that anybody with no experience could easily do an export/import in MSSQLServer 2000.
I appreciate if someone could show me how to the import from a file into a table!
Thanks,
Mitra>
I can say that anybody with
no experience could easily do an export/import in
MSSQLServer 2000.
Anybody with no experience should not mess up my Oracle Databases ! -
How can I use Automator to extract specific Data from a text file?
I have several hundred text files that contain a bunch of information. I only need six values from each file and ideally I need them as columns in an excel file.
How can I use Automator to extract specific Data from the text files and either create a new text file or excel file with the info? I have looked all over but can't find a solution. If anyone could please help I would be eternally grateful!!! If there is another, better solution than automator, please let me know!
Example of File Contents:
Link Time =
DD/MMM/YYYY
Random
Text
161 179
bytes of CODE memory (+ 68 range fill )
16 789
bytes of DATA memory (+ 59 absolute )
1 875
bytes of XDATA memory (+ 1 855 absolute )
90 783
bytes of FARCODE memory
What I would like to have as a final file:
EXCEL COLUMN1
Column 2
Column3
Column4
Column5
Column6
MM/DD/YYYY
filename1
161179
16789
1875
90783
MM/DD/YYYY
filename2
xxxxxx
xxxxx
xxxx
xxxxx
MM/DD/YYYY
filename3
xxxxxx
xxxxx
xxxx
xxxxx
Is this possible? I can't imagine having to go through each and every file one by one. Please help!!!Hello
You may try the following AppleScript script. It will ask you to choose a root folder where to start searching for *.map files and then create a CSV file named "out.csv" on desktop which you may import to Excel.
set f to (choose folder with prompt "Choose the root folder to start searching")'s POSIX path
if f ends with "/" then set f to f's text 1 thru -2
do shell script "/usr/bin/perl -CSDA -w <<'EOF' - " & f's quoted form & " > ~/Desktop/out.csv
use strict;
use open IN => ':crlf';
chdir $ARGV[0] or die qq($!);
local $/ = qq(\\0);
my @ff = map {chomp; $_} qx(find . -type f -iname '*.map' -print0);
local $/ = qq(\\n);
# CSV spec
# - record separator is CRLF
# - field separator is comma
# - every field is quoted
# - text encoding is UTF-8
local $\\ = qq(\\015\\012); # CRLF
local $, = qq(,); # COMMA
# print column header row
my @dd = ('column 1', 'column 2', 'column 3', 'column 4', 'column 5', 'column 6');
print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
# print data row per each file
while (@ff) {
my $f = shift @ff; # file path
if ( ! open(IN, '<', $f) ) {
warn qq(Failed to open $f: $!);
next;
$f =~ s%^.*/%%og; # file name
@dd = ('', $f, '', '', '', '');
while (<IN>) {
chomp;
$dd[0] = \"$2/$1/$3\" if m%Link Time\\s+=\\s+([0-9]{2})/([0-9]{2})/([0-9]{4})%o;
($dd[2] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of CODE\\s/o;
($dd[3] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of DATA\\s/o;
($dd[4] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of XDATA\\s/o;
($dd[5] = $1) =~ s/ //g if m/([0-9 ]+)\\s+bytes of FARCODE\\s/o;
last unless grep { /^$/ } @dd;
close IN;
print map { s/\"/\"\"/og; qq(\").$_.qq(\"); } @dd;
EOF
Hope this may help,
H -
I would like to plott data from a text file in the same way as a media player does from a video file. I’m not sure how to create the pointer slide function. The vi could look something like the attached jpg.
Please, can some one help me?
Martin
Attachments:
Plotting from a text file like a media player example.jpg 61 KBHI Martin,
i am not realy sure what you want!?!?
i think you want to display only a part of the values you read from XYZ
so what you can do:
write all the values in an array.
the size of the array is the max. value of the slide bar
now you can select a part of the array (e.g. values from 100 to 200) and display this with a graph
the other option is to use the history function of the graphes
regards
timo
Maybe you are looking for
-
Logic 8 Crashes and Freezes - please help
Just got my Logic Studio Upgrade (from Pro 7) and installed it. First time I launched, I got one of those scary complete system hardware crashes (where the screen goes grey) as soon as it started scanning for plug-ins. After I rebooted, I removed all
-
ICM_HTTP_CONNECTION_FAILED Error 400
Hello All, i have one synchronous interface on production system. it was running fine till now. But on Sunday we got around 1000 messages in SMQ2. they all are in same queue. But now same interface is running successfully....... (through another queu
-
When I place or receive a call, the volume is way too low. My volume setting on the phone is maxed out. Does anyone have a solution for me? iMac Mac OS X (10.3.7)
-
Hi, i've made my web site using iWeb and uploaded it to my iDisk using iWeb I have a blog page made with iWeb can I use Adobe Contribute CS3 to modify and create blog entries on my site? I ask because I have a friend who i'd like to have a blog on th
-
Smartview VBA HypGetSheetOption problem
I am having an issue where my call to HypGetsheetOption #13 is returning an indiscypherable result. My #Missing label is set to #Missing but the call to retreive this returns garbage. using vba's len function, I see that I have 1 less character then