EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Misc::Off Topic (https://www.eqemulator.org/forums/forumdisplay.php?f=595)
-   -   perl help please (https://www.eqemulator.org/forums/showthread.php?t=25737)

spider661 07-19-2008 05:46 AM

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.

Theeper 07-26-2008 09:18 PM

Why not just import the spells file as a CSV file ?

Andrew80k 07-26-2008 10:24 PM

Quote:

Originally Posted by Theeper (Post 153268)
Why not just import the spells file as a CSV file ?

Yes, or use the DBI.


All times are GMT -4. The time now is 10:09 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.