LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-17-2008, 10:31 AM   #1
shafi2all
LQ Newbie
 
Registered: Apr 2008
Posts: 1

Rep: Reputation: 0
Reading a CSV text file and storing the values in Oracle Database table


Hello,

I want a C programme to read a CSV text file and store the values in table(Oracle database).. when i execute this c-executable the values would read from CSV and transferred to a table present in Oracle..How could i do that?

Shafi
 
Old 04-17-2008, 11:14 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
Haven't used it but it looks like this might be what you want or at least give you ideas about how to do it since the source for what he is doing is available:

http://opencsv.sourceforge.net/
 
Old 04-17-2008, 11:21 AM   #3
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,077

Rep: Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713Reputation: 2713
If you want to break it down into steps:

- Check for the .CSV file you're wanting to open
- If its present, open it
- Connect to your database
- Read each line of the file, splitting the different fields at the commas
- Insert the record(s) into the database, until you hit EOF
- Close the database connection
- Exit

I've done things like this in Perl, using MySQL as the back end, and can usually do it in just a few lines of code. Haven't played with C in quite a while, though.
 
Old 04-17-2008, 01:19 PM   #4
sunils1973
Member
 
Registered: Jan 2007
Location: INDIA
Distribution: Ubuntu, Debian
Posts: 323

Rep: Reputation: 30
In MySQL the LOAD DATA statement can be used to import text from a csv file to a table

ORACLE has also such a command to load data

I think create C program for this purpose is not required
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to store text(strings) in a 2D character array reading from a text file(C++) bewidankit Programming 3 02-14-2008 08:08 AM
looking for a perl script to convert html table data into a csv file swiftguy121 Linux - Software 2 04-25-2007 08:28 PM
Reading Snort Text Log into Database willis3000 Linux - Software 0 03-10-2006 08:25 PM
storing text in a text file for a specified length of time. mrobertson Programming 7 08-02-2005 11:27 AM
bash; reading values from a file km4hr Programming 16 07-28-2005 03:07 PM


All times are GMT -5. The time now is 08:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration