SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru ripcurlksm's Avatar
    Join Date
    Aug 2004
    Location
    San Clemente, CA
    Posts
    859
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    take contents of 300 text files into 300 rows

    I have 300 plain text files that I want to save myself from copy/pasting into each keywords row. The text files are named the same as the row id so it should be easy to match up

    I know this is wrong but I am looking at functionality like this where I can specify a table, and column where it should go:

    LOAD DATA LOCAL INFILE 'C:\Users\User\Desktop\reports\123.txt' INTO TABLE report(keywords) WHERE report_id = '123';
    LOAD DATA LOCAL INFILE 'C:\Users\User\Desktop\reports\456.txt' INTO TABLE report(keywords) WHERE report_id = '456';
    LOAD DATA LOCAL INFILE 'C:\Users\User\Desktop\reports\789.txt' INTO TABLE report(keywords) WHERE report_id = '789';

    if there isnt something like this, I will have to open 123.txt and copy and paste it into the corrosponding row under the keyword column in the report database x300.

    Hope this makes sense. I understand LOAD DATA is used to import entire databases from a text file, but I am looking to just import the data from one text file into a single field.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    You could use PHP to glob() the directory, loop through the resulting array and use file_get_contents() to get the data and create a string for the simple INSERT INTO sql query.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •