Importing a DataSift CSV file in to MySQL

February 28, 2012

DataSift data can be exported from both recordings and historics in either JSON or CSV formats. Depending upon your filter  definition, the fields within the resulting data will vary, therefore making importing the data in to a database such as MySQL a little time consuming.

The below PHP script automatically generates the CREATE TABLE command, along with the LOAD DATA INFILE command, allowing you to create a new table, and import the data quickly and easily.

Usage: Just update the location and name of the CSV file at the top – $myFile = "test.csv";

Feel free to improve and comment and let me know.

https://gist.github.com/1933308

Error when loading gists from http://gist.github.com/.