Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003

    Unanswered: Importing a text file into mySQL

    I have a text file which contains info on auto accounting records. I need to import these into mysql, and there will be a new one everyday. I have it set up right now so that the user selects the file in a browse window, and clicks 'send' and that uploads the portion of the text file to the mysql DB. The problem is I am only taking 4 fields out of the text file presently, but my boss says I need all of them for future use.

    The problem is, the text file varies in length depending on the type of auto accounting records it is. For example, col 1-86 are always the same....but, if col 76 contains a 'A' for accounting...the record layout goes from col 87-200. But if col 76 contains a 'S' for statistical, the record layout is from col 87-235...containing totally different information. How would I deal with importing this information into a mysql table? Do I need to create a second table to store the different type of information?

    I presently only take col 25-27, 30-37, and 39. So I never have to deal with the different types of records.

    Thanks for any help\tips I recieve,

  2. #2
    Join Date
    Dec 2002
    how about using python or php or whatever to read the file and tokenize it. Then you could check when you reach these variables whether you need to read 5 or 15 colums more. After that it΄s just a case of having a connection to mysql so that you can insert the data. Hope this makes some sense to you

Posting Permissions

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