Professional Web Applications Themes

load data assistance - MySQL

hi, I have comma seperated data in a file as below, king, 1000, male, 30 shilpa, 5000, female, 28 john, 4000, male, 34 i would like to selectively load lines which have third column as 'male' into a table, how do i do this using "load data". There is no where clause in "load data" command syntax. tia...

  1. #1

    Default load data assistance

    hi,
    I have comma seperated data in a file as below,

    king, 1000, male, 30
    shilpa, 5000, female, 28
    john, 4000, male, 34

    i would like to selectively load lines which have third column as
    'male' into a table, how do i do this using "load data". There is no
    where clause in "load data" command syntax.

    tia

    devasura@gmail.com Guest

  2. #2

    Default Re: load data assistance


    com wrote: 

    why not just load everything and then select create table?

    strawberry Guest

  3. #3

    Default Re: load data assistance

    > > tiawhy not just load everything and then select create table?

    if i have a lot of data then half the entries would be invalid. In your
    case i have to load all the data then delete unwanted by using

    delect from table1 where gender = 'female';

    I want to selectively load the lines to minimise the load on the server

    tia

    devasura@gmail.com Guest

  4. #4

    Default Re: load data assistance

    com wrote:
     [/ref]
    >
    > if i have a lot of data then half the entries would be invalid. In your
    > case i have to load all the data then delete unwanted by using
    >
    > delect from table1 where gender = 'female';
    >
    > I want to selectively load the lines to minimise the load on the server
    >
    > tia
    >[/ref]


    windows or unix? there may be a way...

    --
    Michael Austin.
    DBA Consultant
    Donations welcomed. Http://www.firstdbasource.com/donations.html
    :)
    Michael Guest

  5. #5

    Default Re: load data assistance

    com wrote: [/ref]
    >
    > if i have a lot of data then half the entries would be invalid. In your
    > case i have to load all the data then delete unwanted by using
    >
    > delect from table1 where gender = 'female';
    >
    > I want to selectively load the lines to minimise the load on the server
    >
    > tia
    >[/ref]

    If this is an INNODB table, you might be able to create a foreign key on
    the column to another table with just 'male' in it.

    Or you can write a program in a language such as Perl, PHP, C, etc.,
    which can do the filtering.


    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  6. #6

    Default Re: load data assistance


    so the only option is to use text filters like grep in linux.
    what about windows?

    tia

    devasura@gmail.com Guest

  7. #7

    Default Re: load data assistance

    com wrote:
     [/ref]
    >
    > if i have a lot of data then half the entries would be invalid. In your
    > case i have to load all the data then delete unwanted by using
    >
    > delect from table1 where gender = 'female';
    >
    > I want to selectively load the lines to minimise the load on the server
    >
    > tia
    >[/ref]

    Unless you are doing ten-thousands of records at a time and you do it more than
    100 times a day, you are not going to touch the load on the server...

    you could:
    (gets all records NOT containing female - because female does contain the word
    male).

    find /I/V "female" infile > outfile
    load outfile
    delete outfile

    for UNIX/Linux:

    grep -iv female infile > outfile
    load the file
    rm outfile

    the odds of having names with the word "female" and in it are remote.
    --
    Michael Austin.
    Database Consultant
    Michael Guest

  8. #8

    Default Re: load data assistance


    <com> wrote in message
    news:googlegroups.com... 


    F:>type file
    king, 1000, male, 30
    shilpa, 5000, female, 28
    john, 4000, male, 34

    F:>findstr /R "\<male\>" file > newfile

    F:>type newfile
    king, 1000, male, 30
    john, 4000, male, 34


    With awk you'll be more precise (you can get a Windows port):

    $ awk '$3 == " male"' FS="," file
    king, 1000, male, 30
    john, 4000, male, 34


    Regards
    Dimitre



    Radoulov, Guest

  9. #9

    Default Re: load data assistance

    On 2 Dec 2006 06:55:56 -0800, com wrote:
     

    grep, gawk, find, ...
     
    --
    ( Kees
    )
    c[_] If only women came with pulldown menus and online help. (#418)
    Kees Guest

Similar Threads

  1. data txt load
    By ocvs in forum Macromedia Flash Data Integration
    Replies: 2
    Last Post: July 27th, 12:13 PM
  2. Load xml data in sepearate mxml file and Populate data
    By indradapps in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: June 7th, 05:44 AM
  3. Data type mismatch error assistance please
    By Me in forum ASP Database
    Replies: 6
    Last Post: August 14th, 08:01 PM
  4. Log shipping / data load
    By Shamim in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 9th, 06:37 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139