Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Lv 31,241 points

Amit

Favorite Answers51%
Answers138
  • Importing Text files into mySQL?

    Looking for help in doing this:

    I have a directory full of text files that are named with an ID and contains body of an article.

    The names are such 1001_1.txt, 1001_2.txt, 1002.txt, 1003.txt, and so forth and so on.

    Basically, I need a script (PHP or otherwise) that would simply put the name of the text file (before the underscore) in a column, and the content of the text file in another column, and if there is any number after the underscore, to put that in one column as well.

    So you would have a table structure looking like this:

    1001 | 1 | content of the text file

    1001 | 2 | content of the text file

    1002 | null | content of the text file

    1003 | null | content of the text file

    Any help on how I can accomplish this would be appreciated.

    There are about 7000 text files that need to be read and imported in the database. Each text file contains only an article of some sort and 1001_1 and 1001_2 would basically contain different bodies of the same article.

    1 AnswerProgramming & Design1 decade ago