User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 455,988 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,790 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1658 | Replies: 1
Reply
Join Date: Feb 2007
Posts: 17
Reputation: vasudha k is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
vasudha k vasudha k is offline Offline
Newbie Poster

Help extracting comma separated values

  #1  
Dec 6th, 2007
Hi ,

Hey I have a small problem.... For a certain field in database, tha values are sent from front end(JSP page) . Each individual value must be extracted and then inserted into the database.....
Before inserting, we have called a procedure which will extract each value and insert....
Moreover , it is only for the first value that we must insert. For all the remaining values , we have to update......


We are stuck up with this..... and some of the attempts we made aren't working....

Can anyone give an idea as to how to implement this code................
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: extracting comma separated values

  #2  
Dec 6th, 2007
what we do in php is, open the csv file using fopen. Then using the filepointer of fopen, we store the csv values in an array. Then access that array. for example, (in php ie.,)
  1. <?php
  2. $fp = fopen("test.csv", "r"); //open the csv file
  3. while ($contents = fgetcsv ($fp, 1000, ";")) { // fetch the contents of the csv file. ';' is the delimiter of the fields in csv file
  4. $name=$contents[0]; //first element of array $contents has $name
  5. //insert to table
  6. $age=$contents[1]; //age is the 2nd element of array
  7. //update the table
  8. }
  9. ?>

Look for a similar function in jsp. (to open the file and get the contents of csv).

Hope it helps.
Naveen
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 9:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC