Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jerauf

macrumors newbie
Original poster
Mar 15, 2007
3
0
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?
 

beefy23

macrumors member
Feb 13, 2007
41
0
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'.
 

ChrisA

macrumors G5
Jan 5, 2006
12,907
2,155
Redondo Beach, California
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.
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.