Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 15, 2007, 08:34 AM   #1
jerauf
macrumors newbie
 
Join Date: Mar 2007
Utility to convert CSV to SQL for import

My new web host doesn't allow importing data from CSV files using PHPmyAdmin. I use Filemaker to build the database. With my old host, I could export to CSV and import that file without problem. The new host doesn't allow this. So I need to import using SQL statements. And, with all of the special characters, going back over all of my data and fixing them with \'s is going to be a nightmare.

Is there a utility that will convert CSV to SQL statements? Or does Filemaker do it and I'm just not seeing it?
jerauf is offline   0 Reply With Quote
Old Mar 15, 2007, 09:34 AM   #2
beefy23
macrumors member
 
Join Date: Feb 2007
Send a message via Skype™ to beefy23
Quote:
Originally Posted by jerauf View Post
My new web host doesn't allow importing data from CSV files using PHPmyAdmin. I use Filemaker to build the database. With my old host, I could export to CSV and import that file without problem. The new host doesn't allow this. So I need to import using SQL statements. And, with all of the special characters, going back over all of my data and fixing them with \'s is going to be a nightmare.

Is there a utility that will convert CSV to SQL statements? Or does Filemaker do it and I'm just not seeing it?
Have you considered using a text editor like Smultron or Textmate to do a global search/replace of the special characters - I don't know Filemaker so I can't say if it has this sort of functionality?

The other thing is that with a text editor you can do some pretty nifty stuff using regular expressions if ordinary search/replace won't 'cut the mustard'.
beefy23 is offline   0 Reply With Quote
Old Mar 15, 2007, 10:36 AM   #3
ChrisA
macrumors G4
 
Join Date: Jan 2006
Location: Redondo Beach, California
Quote:
Originally Posted by jerauf View Post
My new web host doesn't allow importing data from CSV files using PHPmyAdmin. I use Filemaker to build the database. With my old host, I could export to CSV and import that file without problem. The new host doesn't allow this. So I need to import using SQL statements. And, with all of the special characters, going back over all of my data and fixing them with \'s is going to be a nightmare.

Is there a utility that will convert CSV to SQL statements? Or does Filemaker do it and I'm just not seeing it?
Ignore PHPmyAdmin. Login use ssh and run the SQL interpeter.
Which DBMS are you using on the server. Almost all of them have an import utility for CSV files.

If you do have to convert your data to SQL inserts in the past I've used "sed". Sed is a great little editor and it is pretty easy to get it to add the backslashes and SQL syntax. Sed accepts regular expressions and. It can replace tabs with escaped tabs and so on.

But first look at the SQL command line interpeter. I know Postgresql's "psql" wil do what you need.
ChrisA is offline   1 Reply With Quote
Old Mar 15, 2007, 04:16 PM   #4
AlmostThere
macrumors 6502a
 
Join Date: Feb 2005
Location: The royal throne of kings, the sceptred isle, the other Eden, the fortress built
If you really want a GUI tool for this, you could use Aquafold's AquaDataStudio (version 4.x is free for personal use) it will read a csv file and write a load of SQL statements for you through the Tools -> Import Data function.
__________________
Join the army of the dead: http://www.urbandead.com
AlmostThere is offline   0 Reply With Quote
Old Mar 16, 2007, 03:28 AM   #5
garethlewis2
macrumors 6502
 
Join Date: Dec 2006
Since you are on a Mac, use the Unix command line tools. Perl, sed, awk, and even bash could do this. You would have to write a script, and this type of work is what those languages or utilites were written for.
garethlewis2 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
oneSafe Password Manager for Mac - iCloud/Dropbox sync & CSV/Keychain import DonaldSequeira Mac Applications and Mac App Store 0 Apr 2, 2014 10:01 PM
ONESAFE - best Password Manager - iCloud/Dropbox sync and CSV import DonaldSequeira Mac Applications and Mac App Store 4 Mar 24, 2014 09:15 PM
An offline dictionary where one can import a csv file yiannisbot iPhone and iPod touch Apps 0 Feb 14, 2014 10:31 AM
How to convert SQLite schema to CSV format? Narendar Singh iPhone/iPad Programming 3 Jul 15, 2012 11:05 AM

Forum Jump

All times are GMT -5. The time now is 12:47 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC