Importing text file into MySQL?

Discussion in 'Programming/Scripts' started by yakkanti lokeshreddy, Aug 27, 2015.

  1. I have a text file here, that I would like to import into a MySQL database (it's for an result based one).
    The text file looks like this:
    Code:
    Htno Subcode Subname Internal External credits
    112B1A0203 R22021 PULSE & DIGITAL CIRCUITS 15 26 4
    112B1A0203 R22022 POWER SYSTEMS-I 21 26 4
    112B1A0203 R22023 SWITCHING THEORY & LOGIC DESIGN 14 -1 0
    112B1A0203 R22024 ELECTRICAL MACHINES-II 10 22 0
    112B1A0203 R22026 CONTROL SYSTEMS 16 9 0
    112B1A0203 R22029 ELECTRICAL CIRCUIT ANALYSIS-II 10 38 4
    112B1A0205 R22021 PULSE & DIGITAL CIRCUITS 6 34 4
    112B1A0205 R22023 SWITCHING THEORY & LOGIC DESIGN 3 15 0
    112B1A0205 R22024 ELECTRICAL MACHINES-II 6 46 4
    112B1A0205 R22029 ELECTRICAL CIRCUIT ANALYSIS-II 10 32 4
    
    
    
    The result is using an other database, but as test I have created an empty MySQL named "testdb".
    The testdb does not have any tables in it..

    Now how can I import this text file into an empty MySQL database?

    Any help appreciated!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Create a database table with columns that match the columns of your data file e.g. with phpmyadmin and then use e.g. mysqlimport https://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html to load the data into the database. The data file format might be a bit of a problem as it is not clear how the columns ares eparated as the "separator" whitespace is also contained in the subname values.
     
  3. thanks till

    i tried it but i canot upload into this data
    can u try once using following data
     

    Attached Files:

    • 1.txt
      File size:
      38 KB
      Views:
      85

Share This Page