Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Convert CSV data held in a CLOB into columns

Re: Convert CSV data held in a CLOB into columns

From: Vince <vinnyop_at_yahoo.com>
Date: Mon, 10 Dec 2007 08:42:42 -0800 (PST)
Message-ID: <62f07cec-36ba-48fe-8b66-8ad1df96e227@s19g2000prg.googlegroups.com>


On Dec 7, 2:05 pm, jeremy <jeremy0..._at_gmail.com> wrote:
> Oracle 10gR2
>
> Would like to be able to support upload of a CSV file and then populate
> a "staging" table with its contents.
>
> - use first line of file as column names
> - load lines 2 to end of file as rows into a table, populating only
> those columns identified in the header row
>
> The thought was we could load the file into a BLOB (I should mention
> we're using OHS / mod_plsql so this is standard file upload)), convert
> it to CLOB and then (somehow) parse the content.
>
> Antbody any pointers to examples where this has been done before?
>
> Other suggestions? Have thought about external tables - perhaps that is
> a better approach?
>
> --
> jeremy

Jeremy,
I have written a csv parser from a clob before. Basically iterating the clob by the appropriate eol/cr/lf character. In my case, I placed each line's data into an array of varchar data elements. The array was then dealt with in its context of the appropriate table or tables.

Things requiring more thought were whether data elements had text enclosing characters (such as ", as in: 123.00,"Example, comma in the middle of text", More text,...) and figuring out what the EOL character(s) were.

Vince Received on Mon Dec 10 2007 - 10:42:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US