• 0

converting Text file into table in MySQL


Question

I have a folder that contains 50 text files ,i require a program that can read these text files and convert them into tables,i want the primary key to be the name of the text file.

//sample contents of my 1.txt file is as follows

atro

astrology

king

moon

monkey

seven

skin

All the text file contain the information in the same format

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

I have a folder that contains 50 text files ,i require a program that can read these text files and convert them into tables,i want the primary key to be the name of the text file.

<snip>

All the text file contain the information in the same format

So you want 50 files converting into 50 tables, with a primary key bein the name of the file? eh? *headsplodes*

Link to comment
Share on other sites

  • 0

yeah i am lost too

If you had one table with the text files name as the primary key

but if you had a table for each text file the primary key could not be the name of the text file as the primary key has to be unique

Link to comment
Share on other sites

  • 0

The primary key has to be UNIQUE as it is what is used to reference a record in a table.

So if your file (1.txt) contained:

atro

astrology

king

moon

monkey

seven

skin

Then your table would not be able to use the file name as the primary key for each of those records because the file name doesn't change; it will always be 1.txt. Each of those seven records must have a unique primary key.

Link to comment
Share on other sites

This topic is now closed to further replies.