Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

Importing CSV files

Daniele68's profile image Daniele68 posted 13 years ago in Import/Export Permalink
I'm somewhat new to SQL. I had a previous version in which I could select Import, choose CSV then It would allow me to map the fields from my CSV file to the Sql database. first, I don't see that option in this program. Second, I can't seem to import anything at all. What am I doing wrong?
ansgar's profile image ansgar posted 13 years ago Permalink
Simply chose "Import/Export" -> "Import Textfile" and try.
Daniele68's profile image Daniele68 posted 13 years ago Permalink
I've tried the import text file. It doesn't work. Does it matter that my field names in the CSV file are different from the database field names? This is why I was hoping I could map the fields.
Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
ansgar's profile image ansgar posted 13 years ago Permalink
What means "it doesnt work" ? Where? What exactly happens?

With "field names in your CSV-file" I guess you mean the cells in the first line of the file. It doesn't matter how they are named, but in fact it does matter how many columns the CSV-file has. You have to manually sort and (un-)check the columns in the listbox to reflect the structure of your CSV-file. There is no automatism yet which does this job for you.

Maybe this is a future thing for HeidiSQL. As I overthink that, I find that's a cool feature which should be posted to http://rfe.heidisql.com/ .
theone's profile image theone posted 13 years ago Permalink
I'm kind of wrestling with the same issue except that all i need to know is what do I put in the "Lines:" "terminated by" to let it know to start the next line? I'm assuming I would want to have a return here? What do I enter in the box that represents a "return"?
theone's profile image theone posted 13 years ago Permalink
Okay i figured out how to get the import to happen using a comma delimited file but how do I handle a file that has text in fields that also have commas in the sentence? I'm using Excel and i'm sure there is a way to tell it to use something other than a comma for field seperation? Any helpful clues?
siMKin's profile image siMKin posted 13 years ago Permalink
excel probably gives a really good example when you export to (save as) CSV ... :roll:

anyways, you'll have to enclose the values of a field with a special symbol .. for example the " (quote). and whenever this symbol appears as part of the value, you have to escape it with another symbol .. for example the \

"this is \"an\" example", "and this another one"


and i'm not sure if you had figured this out, be a return can be either \r\n, \r or \n, depending on which platform you are (window, mac, linux)
theone's profile image theone posted 13 years ago Permalink
Thanks for your little lesson in db 101. I'm just getting this stuff figured out and this program has been very helpful with the process. :D
theone's profile image theone posted 13 years ago Permalink
Did some looking into Excel to figure out how to use something other than a comma for field ending and could not find anything. But I discovered Open Office in the process which gives you the option select what character you want to use.
siMKin's profile image siMKin posted 13 years ago Permalink
excel automatically compensates for commas by enclosing them between quotes, when saving it as a CSV file

But, don't let stop you from Calc (Open Office)! It's much better the MS Office :)
Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
Code modification/commit from ansgar.becker, 7 years ago, revision 4324
Increase height of memoFindText from 26 to 60 pixels. Accidentally resized to a minimum in r4254. See http://www.heidisql.com/forum.php?t=12064
Code modification/commit from ansgar.becker, 7 years ago, revision 4326
Work around empty body detected in ParseRoutineBody, and get it from information_schema.ROUTINES in that case. See http://www.heidisql.com/forum.php?t=12075 .
mariela21180's profile image mariela21180 posted 2 years ago Permalink

Guys, I find a great tool to import CSV to Heidi and I wanted to share it with you.

On this page I get to convert an .csv file into an SQL command to import: convertcsv.com / csv-to-sql.htm And then I've copied the result text to Heidi and works perfectly

Andrew's profile image Andrew posted 2 years ago Permalink

I've recently started using Heidi after a recommendation. My only problem is up until monday everything was fine. But since I have not been able to import a CSV file. I keep getting a connection error however there is no problem with the connection as I can run queries perfectly fine.

I can even run some of the import as insert statements. Worked fine for 40000+ records. However I need to get nearly 1.5million records into the table and doing it as inserts would take far too long.

BubikolRamios's profile image BubikolRamios posted 2 years ago Permalink

It probably takes connection and then that connection dies on server as it's life time is probably limited on server or elsewhere.

That is, while it imports huge csv. Try to import to local server, if not already ...

Please login to leave a reply, or register at first.