LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 09: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, 10:14 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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, 10:21 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,641

Rep: Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650Reputation: 7650
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, 12:19 PM   #4
sunils1973
Member
 
Registered: Jan 2007
Location: INDIA
Distribution: Ubuntu, Debian
Posts: 340

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 07:08 AM
looking for a perl script to convert html table data into a csv file swiftguy121 Linux - Software 2 04-25-2007 07:28 PM
Reading Snort Text Log into Database willis3000 Linux - Software 0 03-10-2006 07:25 PM
storing text in a text file for a specified length of time. mrobertson Programming 7 08-02-2005 10:27 AM
bash; reading values from a file km4hr Programming 16 07-28-2005 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:15 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
Open Source Consulting | Domain Registration