Batch process to add to a group from csv file

This is a discussion on Batch process to add to a group from csv file within the MySQL Database forums, part of the Database Forums category; I have a newby question here. I have a database that has names and addresses of people (members). I also ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-06-2006
Jack Matthews
 
Posts: n/a
Default Batch process to add to a group from csv file

I have a newby question here.

I have a database that has names and addresses of people (members). I also
have a .csv file with supervisors for each of these members. I want to add
to the database the supervisor that manages them to the database. The field
for supervisor is already a part of the database so that is done. However I
have the lists of supervisors in individual excel workbooks or .csv files
and I want to run a batch file that looksup each member name and then
assigns the supervisor's name to their row and then moves on to the next
member name to repeat until all members have been assigned. What would be
the best way to do this? My programmer says it cannot be done without hours
and hours of work on his part. Any suggestions?

Thanks for your help,

Jack


Reply With Quote
  #2 (permalink)  
Old 09-06-2006
Captain Paralytic
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

> My programmer says it cannot be done without hours
> and hours of work on his part. Any suggestions?


Get a new programmer!
Seriously, this is not difficult (assuming what you have told us is
true), but you do not need a batch file.
Here are 2 methods (there are lots more):
Method 1)
Step 1) Export the members database into Excel
Step 2) Use VLOOKUP to construct the new rows for the members database
(I often us Excel formulas to create all the INSERT or UPDATE queries)
Step 3) Use the output from Excel to update the members table

Method 2)
Step 1) create a temporary table in mysql to hold the member/supervisor
data.
Step 2) Load the temporary table from the csv file
Step 3) Run a single UPDATE query to load the supervisor data into the
members table

I prefer method 2.

Reply With Quote
  #3 (permalink)  
Old 09-06-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

Captain Paralytic wrote:
>>My programmer says it cannot be done without hours
>>and hours of work on his part. Any suggestions?

>
>
> Get a new programmer!
> Seriously, this is not difficult (assuming what you have told us is
> true), but you do not need a batch file.
> Here are 2 methods (there are lots more):
> Method 1)
> Step 1) Export the members database into Excel
> Step 2) Use VLOOKUP to construct the new rows for the members database
> (I often us Excel formulas to create all the INSERT or UPDATE queries)
> Step 3) Use the output from Excel to update the members table
>
> Method 2)
> Step 1) create a temporary table in mysql to hold the member/supervisor
> data.
> Step 2) Load the temporary table from the csv file
> Step 3) Run a single UPDATE query to load the supervisor data into the
> members table
>
> I prefer method 2.
>


Hmmm, that depends on the layout of the tables. If, for instance, the
user table has an id instead of a name, this might now work as well.

Personally I would do it in a batch job. Depending on your table layout
it might even take an hour or two. Just export the .CSV file, read it
one row at a time and update the tables as necessary. Easy in either
Perl or PHP, for instance. A little harder in C++ but not that much.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #4 (permalink)  
Old 09-06-2006
Captain Paralytic
 
Posts: n/a
Default Re: Batch process to add to a group from csv file


Jerry Stuckle wrote:
> Captain Paralytic wrote:
> >>My programmer says it cannot be done without hours
> >>and hours of work on his part. Any suggestions?

> >
> >
> > Get a new programmer!
> > Seriously, this is not difficult (assuming what you have told us is
> > true), but you do not need a batch file.
> > Here are 2 methods (there are lots more):
> > Method 1)
> > Step 1) Export the members database into Excel
> > Step 2) Use VLOOKUP to construct the new rows for the members database
> > (I often us Excel formulas to create all the INSERT or UPDATE queries)
> > Step 3) Use the output from Excel to update the members table
> >
> > Method 2)
> > Step 1) create a temporary table in mysql to hold the member/supervisor
> > data.
> > Step 2) Load the temporary table from the csv file
> > Step 3) Run a single UPDATE query to load the supervisor data into the
> > members table
> >
> > I prefer method 2.
> >

>
> Hmmm, that depends on the layout of the tables. If, for instance, the
> user table has an id instead of a name, this might now work as well.


That was why in included the caveat "(assuming what you have told us is
true)".
The assumption, based on the original post, is that the name field is a
unique reference common to both tables.

But why would you use a batch file when an update query like:

UPDATE members, supervisors
SET members.supervisor = supervisors.supervisor
WHERE members.membername = supervisors.membername

would seem to do the required combination?

Reply With Quote
  #5 (permalink)  
Old 09-06-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

Captain Paralytic wrote:
> Jerry Stuckle wrote:
>
>>Captain Paralytic wrote:
>>
>>>>My programmer says it cannot be done without hours
>>>>and hours of work on his part. Any suggestions?
>>>
>>>
>>>Get a new programmer!
>>>Seriously, this is not difficult (assuming what you have told us is
>>>true), but you do not need a batch file.
>>>Here are 2 methods (there are lots more):
>>>Method 1)
>>>Step 1) Export the members database into Excel
>>>Step 2) Use VLOOKUP to construct the new rows for the members database
>>>(I often us Excel formulas to create all the INSERT or UPDATE queries)
>>>Step 3) Use the output from Excel to update the members table
>>>
>>>Method 2)
>>>Step 1) create a temporary table in mysql to hold the member/supervisor
>>>data.
>>>Step 2) Load the temporary table from the csv file
>>>Step 3) Run a single UPDATE query to load the supervisor data into the
>>>members table
>>>
>>>I prefer method 2.
>>>

>>
>>Hmmm, that depends on the layout of the tables. If, for instance, the
>>user table has an id instead of a name, this might now work as well.

>
>
> That was why in included the caveat "(assuming what you have told us is
> true)".
> The assumption, based on the original post, is that the name field is a
> unique reference common to both tables.
>
> But why would you use a batch file when an update query like:
>
> UPDATE members, supervisors
> SET members.supervisor = supervisors.supervisor
> WHERE members.membername = supervisors.membername
>
> would seem to do the required combination?
>


Actually, it probably isn't. It's probably something like employee id
or similar. Could also be department number.

Text comparisons are very expensive compared to integer comparisons.
And what if you have two supervisors named "john smith"?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #6 (permalink)  
Old 09-06-2006
Captain Paralytic
 
Posts: n/a
Default Re: Batch process to add to a group from csv file


Jerry Stuckle wrote:
> Captain Paralytic wrote:
> > Jerry Stuckle wrote:
> >
> >>Captain Paralytic wrote:
> >>
> >>>>My programmer says it cannot be done without hours
> >>>>and hours of work on his part. Any suggestions?
> >>>
> >>>
> >>>Get a new programmer!
> >>>Seriously, this is not difficult (assuming what you have told us is
> >>>true), but you do not need a batch file.
> >>>Here are 2 methods (there are lots more):
> >>>Method 1)
> >>>Step 1) Export the members database into Excel
> >>>Step 2) Use VLOOKUP to construct the new rows for the members database
> >>>(I often us Excel formulas to create all the INSERT or UPDATE queries)
> >>>Step 3) Use the output from Excel to update the members table
> >>>
> >>>Method 2)
> >>>Step 1) create a temporary table in mysql to hold the member/supervisor
> >>>data.
> >>>Step 2) Load the temporary table from the csv file
> >>>Step 3) Run a single UPDATE query to load the supervisor data into the
> >>>members table
> >>>
> >>>I prefer method 2.
> >>>
> >>
> >>Hmmm, that depends on the layout of the tables. If, for instance, the
> >>user table has an id instead of a name, this might now work as well.

> >
> >
> > That was why in included the caveat "(assuming what you have told us is
> > true)".
> > The assumption, based on the original post, is that the name field is a
> > unique reference common to both tables.
> >
> > But why would you use a batch file when an update query like:
> >
> > UPDATE members, supervisors
> > SET members.supervisor = supervisors.supervisor
> > WHERE members.membername = supervisors.membername
> >
> > would seem to do the required combination?
> >

>
> Actually, it probably isn't. It's probably something like employee id
> or similar. Could also be department number.

I too doubt that the name field is the correct one to use (hence as I
said the caveat). But if the field DOES contain valid and unique data
and further, is all the OP has then that is what has to be used.

> Text comparisons are very expensive compared to integer comparisons.

This is as may be, but whether done in a batch file or as an update
query, from what the OP posted, they will HAVE to be done some time or
other.
My question still stands, why go to the trouble of writing and
executing a batch file when a single update query will do the job as
well?

> And what if you have two supervisors named "john smith"?

Whilst 2 supervisors named John Smith would cause confusion to anyone
using the data, it wouldn't cause a problem in doing the updates as the
supervisor name is not used for lookup or comparison.

Reply With Quote
  #7 (permalink)  
Old 09-06-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

Captain Paralytic wrote:
> Jerry Stuckle wrote:
>
>>Captain Paralytic wrote:
>>
>>>Jerry Stuckle wrote:
>>>
>>>
>>>>Captain Paralytic wrote:
>>>>
>>>>
>>>>>>My programmer says it cannot be done without hours
>>>>>>and hours of work on his part. Any suggestions?
>>>>>
>>>>>
>>>>>Get a new programmer!
>>>>>Seriously, this is not difficult (assuming what you have told us is
>>>>>true), but you do not need a batch file.
>>>>>Here are 2 methods (there are lots more):
>>>>>Method 1)
>>>>>Step 1) Export the members database into Excel
>>>>>Step 2) Use VLOOKUP to construct the new rows for the members database
>>>>>(I often us Excel formulas to create all the INSERT or UPDATE queries)
>>>>>Step 3) Use the output from Excel to update the members table
>>>>>
>>>>>Method 2)
>>>>>Step 1) create a temporary table in mysql to hold the member/supervisor
>>>>>data.
>>>>>Step 2) Load the temporary table from the csv file
>>>>>Step 3) Run a single UPDATE query to load the supervisor data into the
>>>>>members table
>>>>>
>>>>>I prefer method 2.
>>>>>
>>>>
>>>>Hmmm, that depends on the layout of the tables. If, for instance, the
>>>>user table has an id instead of a name, this might now work as well.
>>>
>>>
>>>That was why in included the caveat "(assuming what you have told us is
>>>true)".
>>>The assumption, based on the original post, is that the name field is a
>>>unique reference common to both tables.
>>>
>>>But why would you use a batch file when an update query like:
>>>
>>>UPDATE members, supervisors
>>>SET members.supervisor = supervisors.supervisor
>>>WHERE members.membername = supervisors.membername
>>>
>>>would seem to do the required combination?
>>>

>>
>>Actually, it probably isn't. It's probably something like employee id
>>or similar. Could also be department number.

>
> I too doubt that the name field is the correct one to use (hence as I
> said the caveat). But if the field DOES contain valid and unique data
> and further, is all the OP has then that is what has to be used.
>
>
>>Text comparisons are very expensive compared to integer comparisons.

>
> This is as may be, but whether done in a batch file or as an update
> query, from what the OP posted, they will HAVE to be done some time or
> other.
> My question still stands, why go to the trouble of writing and
> executing a batch file when a single update query will do the job as
> well?
>


Yes, but they have an employee id or similar, the text comparison only
needs to be done when inserting the data. Later an int comparison can
be done.

And it's not quite as simple as you make it out to be. You have to go
through a lot of steps - exporting the database, lookups, etc. In the
time it takes them to go through all those steps one could easily write
a PHP batch job to do the work.

>
>>And what if you have two supervisors named "john smith"?

>
> Whilst 2 supervisors named John Smith would cause confusion to anyone
> using the data, it wouldn't cause a problem in doing the updates as the
> supervisor name is not used for lookup or comparison.
>


What are you using then?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #8 (permalink)  
Old 09-06-2006
Paul Lautman
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

Jerry Stuckle wrote:

>>
>>> And what if you have two supervisors named "john smith"?

>>
>> Whilst 2 supervisors named John Smith would cause confusion to anyone
>> using the data, it wouldn't cause a problem in doing the updates as
>> the supervisor name is not used for lookup or comparison.
>>

>
> What are you using then?


What am I using for what?


Reply With Quote
  #9 (permalink)  
Old 09-06-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

Paul Lautman wrote:
> Jerry Stuckle wrote:
>
>
>>>>And what if you have two supervisors named "john smith"?
>>>
>>>Whilst 2 supervisors named John Smith would cause confusion to anyone
>>>using the data, it wouldn't cause a problem in doing the updates as
>>>the supervisor name is not used for lookup or comparison.
>>>

>>
>>What are you using then?

>
>
> What am I using for what?
>
>


For the comparison. It can't be the name.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #10 (permalink)  
Old 09-07-2006
Jack Matthews
 
Posts: n/a
Default Re: Batch process to add to a group from csv file

Well, yes this seems right to me. There are no duplicate supervisor names.
and the names are unique. To my knowledge there is no member id. I suppose I
could ask for a table layout or something and see if there is an integer
associated with the name.

Thanks for your input.

Jack


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 05:58 AM.


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