How to load unstructured data [message #579246] |
Sun, 10 March 2013 09:43  |
 |
progkcp
Messages: 10 Registered: March 2013 Location: Washington DC USA
|
Junior Member |
|
|
How to get ill-formatted data into Oracle table?
I'm trying to load a large amount of data that is not arranged into neat columns and doesn't have proper record delimiters.
I'd like to use sql loader but I don't think that will work with unstructured data.
I'm reading that perhaps using an external table would be the best way to do it.
It's sample census data and I've attached a single record to look at.
Any suggestions would be appreciated.
|
|
|
|
Re: How to load unstructured data [message #579249 is a reply to message #579247] |
Sun, 10 March 2013 10:19   |
 |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
External table or SQL*Loader - won't make much difference here. It appears that you might need to load the whole "record" (which might be difficult as you don't know record delimiters) into a single-column table, such ascreate table my_load
(col varchar2(4000)); and then parse data you find in there. If - as BlackSwan pointed out - record length is larger that 4000 characters, you might need to use CLOB instead.
Where did you get such a file from? Can't you negotiate different (better) file structure? You know how it goes ... garbage in, garbage out.
[Updated on: Sun, 10 March 2013 10:19] Report message to a moderator
|
|
|
|
Re: How to load unstructured data [message #579269 is a reply to message #579249] |
Sun, 10 March 2013 20:30  |
 |
progkcp
Messages: 10 Registered: March 2013 Location: Washington DC USA
|
Junior Member |
|
|
Okay, I figured out how to get this big un-delimited string into a table.
As suggested, I created a table with a clob column and then used SQL Loader to insert the whole thing into a single record.
Each record ended with the same thing, Point"}}
I used the stream record format functionality of sql loader and it worked.
Thank you.
desc t
Name Null Type
---- ---- ----
X CLOB
load data
infile '/home/oracle/Data/census_data_sample.tsv' "str 'Point\"}}'"
truncate
into table T
( x position(01:5000) char
)
|
|
|