Bluehost.com Web Hosting $6.95

load data assistance

This is a discussion on load data assistance within the MySQL Database forums, part of the Database Forums category; hi, I have comma seperated data in a file as below, king, 1000, male, 30 shilpa, 5000, female, 28 john, ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-02-2006
devasura@gmail.com
 
Posts: n/a
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

Reply With Quote
  #2 (permalink)  
Old 12-02-2006
strawberry
 
Posts: n/a
Default Re: load data assistance


devasura@gmail.com wrote:
> 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


why not just load everything and then select create table?

Reply With Quote
  #3 (permalink)  
Old 12-02-2006
devasura@gmail.com
 
Posts: n/a
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

Reply With Quote
  #4 (permalink)  
Old 12-02-2006
Michael Austin
 
Posts: n/a
Default Re: load data assistance

devasura@gmail.com wrote:

> > > 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
>



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

--
Michael Austin.
DBA Consultant
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Reply With Quote
  #5 (permalink)  
Old 12-02-2006
Jerry Stuckle
 
Posts: n/a
Default Re: load data assistance

devasura@gmail.com wrote:
> > > 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
>


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.
jstucklex@attglobal.net
==================
Reply With Quote
  #6 (permalink)  
Old 12-02-2006
devasura@gmail.com
 
Posts: n/a
Default Re: load data assistance


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

tia

Reply With Quote
  #7 (permalink)  
Old 12-02-2006
Michael Austin
 
Posts: n/a
Default Re: load data assistance

devasura@gmail.com wrote:

> > > 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
>


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
Reply With Quote
  #8 (permalink)  
Old 12-02-2006
Radoulov, Dimitre
 
Posts: n/a
Default Re: load data assistance


<devasura@gmail.com> wrote in message
news:1165071356.693049.28780@l12g2000cwl.googlegro ups.com...
>
> so the only option is to use text filters like grep in linux.
> what about windows?



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



Reply With Quote
  #9 (permalink)  
Old 12-02-2006
Kees Nuyt
 
Posts: n/a
Default Re: load data assistance

On 2 Dec 2006 06:55:56 -0800, devasura@gmail.com wrote:

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


grep, gawk, find, ...

>tia

--
( Kees
)
c[_] If only women came with pulldown menus and online help. (#418)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:23 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0