Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am very confused about LOAD DATA INFILE

after searching SO and google I have found no help on what I am attempting to do. I want to create a new table, and load the contents of a csv file. The csv files first row is the column names I want.

Or if that cannot be done, how can I load the file without knowing how many columns exist?

LOAD DATA INFILE 'file.txt'
  INTO TABLE t1
  (... unknown number of columns ...);
share|improve this question
LOAD DATA INFILE 'file.csv' INTO TABLE t1? – Shef Aug 8 '11 at 16:07
That will only work assuming the table has the correct number of columns to begin with. – rlemon Aug 8 '11 at 16:08

1 Answer

up vote 0 down vote accepted

You're going to need a tool other than mysql to load csvs without a predetermined schema.

share|improve this answer
thats what I feared.. can you suggest any (hopefully free) good ones? – rlemon Aug 8 '11 at 18:22
I don't know of any off hand, it would be pretty simple to code one up though. Do you know any scripting languages? – PMV Aug 8 '11 at 18:42
Ok well I just solved my own problem . I am working with a rather large export from another program. The export only allows CSV exports, however it is outputting a invalid file. (problems escaping characters) - I did find the main mdf file .. so now i'm working on hacking into that. :) – rlemon Aug 8 '11 at 19:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.