NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: olu on October 06, 2013, 10:55:57 PM

Title: Import CSV file
Post by: olu on October 06, 2013, 10:55:57 PM
Please what is the best way to import a csv file and write it into my database. I have a contact list in csv format that I need to import into my application contact file (backend sql). I was going to use office inside, but only got version 2 and the server has not got office installed on it. Will office inside work without office on the server
Title: Re: Import CSV file
Post by: Bruce on October 06, 2013, 11:19:33 PM
Hi Olu,

there are lots of ways to do this - Office Inside is one, but might be overkill for a CSV file.

a) Declare a table in your dictionary - use Basic driver, and then just loop through this table (perhaps in a process procedure) adding the records to your other table?

b) Use stringTheory =
loadFile
split on CRLF
for each line
  split again on ,  (using a second st object)
  copy fields into your record and save new record

Personally I'd use b) - especially if this was a one-time import (because then no dict structure required).

cheers
Bruce

Title: Re: Import CSV file
Post by: olu on October 09, 2013, 12:20:44 AM
Thanks bruce. Not only was I able to use your advice (b) to get an import to work but also was able to use the stringtheory to do export as well. Thanks.