Show HN: Convert CSV files into MySQL insert scripts
database-import-scriptor.appspot.com
database-import-scriptor.appspot.com
LOAD DATA INFILE 'data.csv' INTO TABLE mytable
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES;Keep on making new (to you) things, keep a good log of what you have done (GitHub) - eventually you will make new (to anyone) things.
i.e. "A testing utility for database migrations"
Loader from Several Nines, is a tool for doing parallel loads of CSV into MySQL and MariaDB https://github.com/severalnines/loader
Mydumper is a threaded dump and load tool for MySQL/MariaDB. https://launchpad.net/mydumper
Tungsten Replicate can do batch load replication into any external datasource http://docs.continuent.com/tungsten-replicator-3.0/deploymen... So long as you have a script for it: https://code.google.com/p/tungsten-replicator/source/browse/...
EDIT: A fun extra, https://mariadb.com/kb/en/mariadb/documentation/storage-engi...
But uploading your files to some site that reformats plain text, this does not belong on hacker news imho.
That said, I can't see how the OP actually helps me with that.
LOAD DATA INFILE 'people.txt'
INTO TABLE Person (@first, @last, date_of_birth)
SET full_name = CONCAT(LEFT(@first, 1), '. ', @last);
You can even do funky stuff like lookups: LOAD DATA INFILE 'projects.txt'
INTO TABLE Projects(@first, @last, project)
SET person_id =
(SELECT id FROM people
WHERE name = CONCAT(@first, ' ', @last) LIMIT 1);Why isn't this just done client-side in Javascript?
There is also a visual drawing to help you connect the dots between the properties of the uploaded file vs. the properties of the objects.
This way, all information gets loaded into the db from a single import, in the correct table.
I could seperate it in a opensource project i suppose, if anyone is interested.
The following was returned: CREATE TABLE testblanks (Column_1 NUMERIC(32, 16),Column_2 VARCHAR(5) CHARACTER SET utf8,Column_3 VARCHAR(5) CHARACTER SET utf8); INSERT INTO testblanks VALUES (1997,' Ford',' E350');
That was in accordance with http://tools.ietf.org/html/rfc4180
Cool!
But the CSV format has a lot of "gotchas." See, for example, http://discuss.fogcreek.com/joelonsoftware3/default.asp?cmd=.... Especially the rant about the Microsoft version of CSV.
In the wild, CSV is less a format and more a meta-format (and a subset of the *SV family) with plenty of variability between dialects.
Can I suggest another idea? Take JSON files, and convert them into MySQL, postgres etc insert/update scripts. There is a need for this. For example, I run this hobby site http://kivatools.com that imports tons of data from kiva.org - their data dumps are in json/xml format. so I've a script that refreshes the db every night, with a couple of gigs of data. It would be very useful if there was a service that can take a url (or file), and convert json/xml into mysql scripts.
Shameless plug: I built an in-browser tool to generate SQL queries from Excel XLS/XLSX/XLSB files: http://sheetjs.com/sexql/
Discussion: https://news.ycombinator.com/item?id=7392665
Field1,Field2,Field3,Int,Float,Quoted
This,is,a,12,1.2,"""file"""
...and it returned an empty textarea.MongoDB is coming soon.
http://utilitymill.com/utility/csv_to_create_table/
You just paste the content from excel or a csv.
It actually tries to figure out the data types and creates a table for you as well.
Allows for quite a few options.
HACKER news, not noobs-that-cant-do-shit.
Reformatting of ascii/text data, a csv, is not rocket science. Nor 'hacker (news) quality'.
And i hope that nobody afterwards realises that they should not have uploaded their csv file to your website hosted by nsa friendly google. Also adding a warning that people are submitting their data to (google, 3rd party servers you don't control) servers, would be nicer, and makes people perhaps aware that their data goes further then only their own browser.