#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Need help to parse a TXT file


    I am fairly new to RegEx, so any help is most appreciated.
    I'm trying to create an extract, that is based on a TXT file (sample: tny.cz/130ca471). For this, the most appropriate approach seemed to run a RegEx string replace. But I'm basically stuck at step one.

    The end result should be something like this:
    (images.wikia.nocookie.net/__cb20120509124740/jaggedalliance/images/0/05/Tables.jpg)

    So basically, from the TXT sample, every line with "//" and two digits should be the new line seperator and the digits agter "Agility", etc. should be seperated by some delimiter, so I can import it as a CSV.
    Hope I was somewhat clear

    Thanks in advance!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42
    Ok, What do you want this .txt file to look like so you can import it:
    Code:
    //Faction_HumanPlayer   = 0
    //kFaction_HumanMilitia = 1      
    //Faction_Deidranna     = 2
    //Faction_HillBillies	= 3
    //Faction_KillTarget   	= 4
    //Faction_VillagePeople = 5
    
    //naked torso and legs:
    //m, f+10, c+20
    //Torso 2000 - white
    //Torso 2001 - brown
    //Torso 2002 - black
    
    // Add Trait by writing "Trait <TraitName>"
    // TraitNames: 
    // "ShotgunAdept", "ShotgunExpert", "HandgunAdept", "HandgunExpert", 
    // "AssaultRifleAdept", "AssaultRifleExpert", "SniperRifleAdept", "SniperRifleExpert", 
    // "MachineGunAdept", "MachineGunExpert", "SubmachineGunAdept", "SubmachineGunExpert", 
    // "ExplosivesAdept", "ExplosivesExpert", "MeleeAdept", "MeleeExpert",
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    Tallahassee
    Posts
    5
    Rep Power
    0

    Try using notepad++


    RegEx isn't for reading files, but for parsing text information.



    You should use an appropriate method (ie: using a StreamReader) to read the file. Once you have the text in place, you can use Regular expressions to parse part or all of the text.
    If you want help with the regular expressions, however, we need to see what type of data you are parsing, and what you want to extract.
    ReGex is half for reading files.

IMN logo majestic logo threadwatch logo seochat tools logo