Go Back   EQEmulator Home > EQEmulator Forums > Misc > Misc::Off Topic

Misc::Off Topic Want to talk about something that has nothing to do with EverQuest or the emulator? Post here.

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2008, 05:46 AM
spider661
Discordant
 
Join Date: Oct 2005
Location: michigain
Posts: 260
Default perl help please

im trying to make a perl file that will take all the info from them spell_us.txt file and place it into an sql file i can import into my database but its not working can anyone help please?

Code:
#!/usr/bin/perl -w
#
# Imports spells from spell_us.txt to spell table, as described in the config below

$spellfile="spells_us.txt";
$sqlspellfile="allspells.sql";
$tbspells = "spells";
#
  open FS,"> $sqlspellfile";
#
print "\nLoading spells from $spellfile... ";
@ids=`$spellfile`;
print "done";
#
print "\nUploading spells to the file... \n";

$cpt=0;
foreach (@ids) {
  $_ =~ s/\"/\"/g;
  @i=split(/\^/,$_);
  if ($i[0]>0) {
    $cpt++;
    $query="INSERT INTO $tbspells ".
            "SET spellid=".$i[0].
                ",name=\"".$i[1].
                "\",castonyou=\"".$i[6].
                "\",castonother=\"".$i[7].
                "\",fading=\"".$i[8].
                "\",range=".($i[9]!=""?$i[9]:0).
                ",aoerange=".($i[10]!=""?$i[10]:0).
                ",casttime=".($i[13]!=""?$i[13]:0).
                ",recoverytime=".($i[14]!=""?$i[14]:0).
                ",recasttime=".($i[15]!=""?$i[15]:0).
                ",buffformula=".($i[16]!=""?$i[16]:0).
                ",buffduration=".($i[17]!=""?$i[17]:0).
                ",aoeduration=".($i[18]!=""?$i[18]:0).
                ",targettype=".($i[98]!=""?$i[98]:0).
                ",skill=".($i[100]!=""?$i[100]:0).
                ",timeofday=".($i[103]!=""?$i[103]:0).
                ",mana=".($i[19]!=""?$i[19]:0);

	# formulas
    for ($n=1; $n<=12; $n++) { $query=$query.
                ",buff$n=".($i[85+$n]!=""?$i[85+$n]:0).
                ",buff".$n."val=".($i[19+$n]!=""?$i[19+$n]:0).
                ",buff".$n."max=".($i[43+$n]!=""?$i[43+$n]:0).
                ",buff".$n."form=".($i[69+$n]!=""?$i[69+$n]:0); }

    # lvls per class
    for ($n=1; $n<=16; $n++) { $query=$query.",level$n=".$i[103+$n]; }
    for ($n=1; $n<=4; $n++) { 
      $query=$query.
             ",regent".$n."_id=".($i[57+$n]!=""?$i[57+$n]:0).
             ",regent".$n."_count=".($i[61+$n]!=""?$i[61+$n]:0);
    }


      print FS $query.";\n";
  }
  if ($cpt%100==0) { print "\n$cpt spells uploaded..."; }
}
print "\n\n";

close FS;
print "done, spells table full\n\n";
it just say Loading spells from spells_us.txt... and just sits there i even tried cutting out most the spells just to see if it was just taking along time to read but nothing it just sits there and does nothing if i close the spell file that opens then it says the rest of the text like it finished but did not fill the sql file.
Reply With Quote
  #2  
Old 07-26-2008, 09:18 PM
Theeper
Discordant
 
Join Date: May 2004
Posts: 290
Default

Why not just import the spells file as a CSV file ?
Reply With Quote
  #3  
Old 07-26-2008, 10:24 PM
Andrew80k
Dragon
 
Join Date: Feb 2007
Posts: 659
Default

Quote:
Originally Posted by Theeper View Post
Why not just import the spells file as a CSV file ?
Yes, or use the DBI.
Reply With Quote
Reply


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 On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:31 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3