Home » SQL & PL/SQL » SQL & PL/SQL » number of columns in csv file
number of columns in csv file [message #202459] Thu, 09 November 2006 22:50 Go to next message
monasingh
Messages: 229
Registered: May 2006
Location: Mumbai
Senior Member

Hi,
These days I am working on converting sql to csv file.
I am familiar with that and know how to do that.
I want to know the number of columns with data in a csv file through sql query.

Please advice me how can I know the number of columns in a csv file.

Thanks,
Mona
Re: number of columns in csv file [message #202476 is a reply to message #202459] Fri, 10 November 2006 00:20 Go to previous messageGo to next message
ehegagoka
Messages: 493
Registered: July 2005
Senior Member
hi!,
count the "comma" + 1

rhani
Re: number of columns in csv file [message #202508 is a reply to message #202476] Fri, 10 November 2006 02:10 Go to previous messageGo to next message
monasingh
Messages: 229
Registered: May 2006
Location: Mumbai
Senior Member

Thanks Rhani but I want to know how can I do that. I mean how to read the csv file through sql query and know the number of columns.

Thanks,
MOna
Re: number of columns in csv file [message #202510 is a reply to message #202508] Fri, 10 November 2006 02:16 Go to previous message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If your Oracle version supports it, use of an external table could be useful in this case. Otherwise, open the CSV file in any text editor, copy one line and paste it as an argument of string function(s) you'll use to count commas, such as

SELECT count_commas('this, is, a, line, coppied, from, CSV, file')
FROM dual;
Previous Topic: qns about triggers, pl/table
Next Topic: import from excel
Goto Forum:
  


Current Time: Fri Dec 06 22:29:20 CST 2024