Results 1 to 7 of 7

Thread: Need help

  1. #1
    Join Date
    Sep 2015
    Posts
    4
    Provided Answers: 1

    Answered: Need help

    I have a problem and i wonder if someone can help me with it , thanks

    So , how do i start , ok i have
    1.DATABASE = Vlad
    2.A table in Vlad = orase
    My question is how do i import a Text Document(.txt) with x records INTO orase?
    My current orase table has exactlly this stats :

    CREATE TABLE `orase` (
    `x` decimal(4,2) DEFAULT NULL,
    `y` decimal(4,2) DEFAULT NULL,
    `localitate` varchar(20) DEFAULT NULL,
    `judet` varchar(40) DEFAULT NULL,
    `codjudet` varchar(2) DEFAULT NULL,
    `populatie` int(11) DEFAULT NULL,
    `regiune` varchar(100) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8

    My import .txt document has these records:
    "X","Y","NUME","JUDET","JUDET AUTO","POPULATIE (in 2002)","REGIUNE"
    "22.94";"46.46";"Deve";"Alba";"AB";"44";"Centr u"
    "22.94";"46.44";"Dupa Plese";"Alba";"AB";"174";"Centru"
    "22.96";"46.46";"Fata";"Alba";"AB";"318";"Cent ru"
    "22.93";"46.45";"Plesesti";"Alba";"AB";"71";"Centr u"
    "22.93";"46.44";"Potionci";"Alba";"AB";"88";"Centr u" ETC

    I simply tried to do it as normal : LOAD DATA LOCAL INFILE "C:/Users/Vlad/Desktop/enunt/orase3.txt"
    INTO TABLE orase and doesn t work. HELP!
    What it happens is that all of my fields are importing with NULL value , every row , every column and i don t udnerstand why.

  2. Best Answer
    Posted by vlad1371

    "
    Quote Originally Posted by healdem View Post
    your data is separated by semi colons, but you are specifying separated by , in your script

    instead use


    you have column names in the first row of your data file, which don't match the column names of the destination table.
    ..that explains the first 4 error messages
    Id suggest deleting the first row of the file so it only contains data
    Cheers man , it worked , rows inserted into table !! , i still have a small problem but they are all in except first row wich has still NULL values inside the columns."


  3. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,418
    Provided Answers: 7
    have though about doing it in 2 steps
    get the data into SQL first as a tmp table then do a append in the next step
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  4. #3
    Join Date
    Sep 2015
    Posts
    1
    Quote Originally Posted by vlad1371 View Post
    I simply tried to do it as normal : LOAD DATA LOCAL INFILE "C:/Users/Vlad/Desktop/enunt/orase3.txt"
    INTO TABLE orase and doesn t work. HELP!
    Did you try FIELDS TERMINATED BY ??

  5. #4
    Join Date
    Sep 2015
    Posts
    4
    Provided Answers: 1

    Insert data issue

    Yes , also posted image with the problem , same result
    Attached Thumbnails Attached Thumbnails Yes.jpg  

  6. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    your data is separated by semi colons, but you are specifying separated by , in your script
    fields terminated by ','
    instead use
    fields terminated by ';'
    you have column names in the first row of your data file, which don't match the column names of the destination table.
    ..that explains the first 4 error messages
    Id suggest deleting the first row of the file so it only contains data
    I'd rather be riding on the Tiger 800 or the Norton

  7. #6
    Join Date
    Sep 2015
    Posts
    4
    Provided Answers: 1

    Insert data

    Quote Originally Posted by healdem View Post
    your data is separated by semi colons, but you are specifying separated by , in your script

    instead use


    you have column names in the first row of your data file, which don't match the column names of the destination table.
    ..that explains the first 4 error messages
    Id suggest deleting the first row of the file so it only contains data
    Cheers man , it worked , rows inserted into table !! , i still have a small problem but they are all in except first row wich has still NULL values inside the columns.
    Attached Thumbnails Attached Thumbnails it worked1.jpg  

  8. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by vlad1371 View Post
    Cheers man , it worked , rows inserted into table !! , i still have a small problem but they are all in except first row wich has still NULL values inside the columns.
    see post #5
    you have column names in the first row of your data file, which don't match the column names of the destination table.
    ..that explains the first 4 error messages
    Id suggest deleting the first row of the file so it only contains data
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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