Jump to content

Building an array from a csv file


Gwendolyne

Recommended Posts

I am writing a process to automate the creation of cre files from an OpenOffice sheet saved as csv.

 

For the moment, I use this code :

ACTION_DEFINE_ASSOCIATIVE_ARRAY Creatures_NPC BEGIN
// Code        Source     Gender      General     Race       Réac    Alg      Classe    Lv1 Lv2 Lv3        Kit         Anim    |     XP         HP        max        AC        TH        ApR     |    FO     Ex        IN    SA    DE    CO    CH    |    Mor    br    rc    Rép     AC-Cr     AC-Mi     AC-Pi     AC-Sl    STD    STW    STP    STB    STS     | ResFi   ResCd   ResEl   ResAc    MR       ResSl   ResCr   ResPi   ResMi |    Metal   Minor  Major    Skin  Leather  Armor    Hair  |    Portrait     Sc_Over     Sc_Clas     Sc_Race     Sc_Génl     Sc_Deft       Nom        Dialogue      Sons     | Flags  Status | Move | Thief     HS        Ill        Traps    Lock    MoveS    FRT        Pick |    Lore  |    Gold  Equip     | Sorts | BSW LSW SSW AXE 2HS KAT SCI DAG WHA CLB SPR HLB FLA MAC STF-CBW LBW SBW DRT SLG-2HD S&S 1WP 2WP | Armesx | Bump Inv BS  Inf   Immunités    Specific RdSt FSt FTH FJS  FHP Max RdHP    Dé_+   FRep      Nom    =>    Fichier
//- 0 -------- 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 --------------------------------------
//GW0001Fi,    GWCreNul,    H,        HUM,    HUMAN,        N,    NN,    INNOCENT,    1,    0,    0,    NO_KIT,        PEASANTM,    20,        10,        ID,        10,        20,        1,        11,    0,        11,    11,    11,    12,    10,        10,    5,    60,    10,        0,        0,        0,        0,    16,    17,    18,    20,    19,        0,        0,        0,        0,        0,        0,        0,        0,        0,        30,        105,    75,        12,        54,        28,        136,        ID,            ID,            NO,            NO,            NO,            NO,            ID,            ID,        GWHOMME,    NONE,    NONE,    NO,        N,    0,        0,        0,        0,        0,        0,        0,        0,        0,        N,        N,        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,        N,        N,    N,    N,    N,        NO,        XXXXXXXX,    Y,    Y,    N,    N,    Y,    Y,    N,    0,    0,    N,    6001001    => GW0001Fi    // Firmin
...
END


ACTION_PHP_EACH Creatures_NPC AS donnees => Creature BEGIN
...

I wish to use the Creatures_NPC.csv file instead of this table.

 

How can I do this?

Link to comment

If there is no easy way to do it, I think the best (according to my skills) is to copy paste my csv file into a blank tph file and just add two lines (ACTION_DEFINE_ASSOCIATIVE_ARRAY Creatures_NPC BEGIN and END) at the top and and the bottom.of the file.

 

Then INCLUDE it into my process. ;)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...