www.webdeveloper.com
Results 1 to 5 of 5

Thread: Need script that extract text parts from .txt file

  1. #1
    Join Date
    Apr 2011
    Posts
    8

    Need script that extract text parts from .txt file

    I need a small script created on any kind of plattform I can use free of charge on a PC. The script could use regular expressions (egrep) or something similar to extract small pieces of information from .txt files, and put this info in a new comma separated .txt. Like this:

    1. User put into script the number of iterations to loop (into the code). From A to B. The iterations is the same as the number of files to process.

    2. In a set directory, the .txt files have prefixes [001_, 002_ etc]. Script loads the first file.

    3. Script checks the FIRST row for a match of [ N], and extract the part between the before N and the previous on that row. (Example: 00 4430.7486 N 06417.4951 W). If no match, then script instead check on that FIRST row a match of [,N] and extract the part between the , before N and the previous , on that row. (Example: 0,4430.7483,"N",6417.4969,"W")

    4. Script checks the FIRST row for a match of [ W], and extract the part between the before W and the previous on that row. (Example: 00 4430.7486 N 06417.4951 W). If no match, then script instead check on that FIRST row a match of [,W] and extract the part between the , before W and the previous , on that row. (Example: 0,4430.7483,"N",6417.4969,"W")

    5. Script does the same thing as on 3 above, but for the LAST row in the current .txt file.

    6. Script does the same thing as on 4 above, but for the LAST row in the current .txt file.

    7. Script creates a new .txt file with: loop iteration number, Extraction in 3, Exctraction in 4, Extraction in 5, Extraction in 6. (Example: 001, 4413.7896, 6413.7896, 4412.1256, 6415.2223)

    8. Script starts over with next iteration in loop, loads a new .txt file and write a new row in the created .txt file for each round.

    Could someone help me with this ? It for a hobby project.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,528
    You can pretty easily install PHP or Python on a PC, and both languages have good regular expression support, or even JavaScript, I suppose. It would mostly depend on which you're most comfortable with, unless you're hoping to find some script that you can use "out of the box"?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,405
    As NogDog says, PHP or Python. I have no experience of Python other than installing it and following some examples but I know PHP could do exactly what you are asking.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  4. #4
    Join Date
    Apr 2011
    Posts
    8
    Quote Originally Posted by \\.\ View Post
    As NogDog says, PHP or Python. I have no experience of Python other than installing it and following some examples but I know PHP could do exactly what you are asking.
    Problem is I have no experience in programming. Zip to none. I just hoped someone could help me write that script.

  5. #5
    Join Date
    Jan 2014
    Posts
    120
    Thanks for sharing good information,with us I strongly believe it is helpful for me as well as my forum friends...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles