Sunday, June 9, 2013

import large csv files intp mysql

you can edit the php.ini

or

i am using XAMPP 1.8.1 on Windows 7 Ultimate Edition

my xampp directory >>> D:\xampp
and database >>> sampledb

copy the data file inside D:\xampp\mysql\data\sampledb

CREATE TABLE IF NOT EXISTS `table2` (
  `FirstName` text,
  `LastName` text,
  `Company` text,
  `Address` text,
  `City` text,
  `County` text,
  `State` text,
  `ZIP` text,
  `Phone` text,
  `Fax` text,
  `Email` text,
  `Web` text
)

* this is not may not be the ideal way create table
   really wanted to create the table in with the loading of data and add the auto-incremental field

my data file is around 22MB and 349996 rows

LOAD DATA INFILE 'data.txt' INTO TABLE table2
  FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  LINES TERMINATED BY '\r\n'
  IGNORE 1 LINES;


No comments:

Post a Comment

About

Blogger templates