Results 1 to 9 of 9

Thread: Extracting data from .txt to .xls?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Extracting data from .txt to .xls?

    Hi guys, I need your help! I want to extract some numerical values at the end of a batch of text files. The data looks like this.

    118,2084400000.
    192,562788000.
    226,2084400000.
    1826,681124002.440932
    1877,1612346469.56606
    1913,94725834.3182483
    1934,256142956.993768
    1960,530178195.204839
    1981,1926830586.69152

    I need to extract the bolded numbers after the first number and comma to an excel (or rather openoffice calc) file for further editing. It is far too tedious and time consuming to do it by hand for the 168 similar files so if you can tell me how to do this in batches, it would be much appreciated!

    Hellenic Air Force - Death, Destruction and Mayhem!

  2. #2
    Freddie's Avatar The Voice of Reason
    Patrician

    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,534

    Default Re: Extracting data from .txt to .xls?

    Open up Excel>Open>(.txt file name)>open. Excel will then open up a Wizard, on the second screen you can add in breaks to the numbers so move the line across 4 places and click finish and you should find the first non bold numbers appear in column A and the bold numbers in column B.

  3. #3

    Default Re: Extracting data from .txt to .xls?

    That part is the at the very end of a few-thousands-lines text file. 807 pages to be precise. But I want just those 9 lines. Plus, I would like to do this for multiple files at the same time if possible. A script would work I guess, but I have no idea how to write the code.

    Hellenic Air Force - Death, Destruction and Mayhem!

  4. #4
    Friend
    Moderator Emeritus

    Join Date
    Oct 2006
    Location
    Beautiful America
    Posts
    8,626

    Default Re: Extracting data from .txt to .xls?

    I had most of the necessary functions on had from a recent project so I threw this together.

    Put the app in the folder with your files, and run it. It will say what to do.

    It'll get just what you want from all the files in the same folder with it, and put these results in a text file. You can copy them into excel from there.


    Retired moderator of TWC
    | Under the patronage of Atterdag

  5. #5

    Default Re: Extracting data from .txt to .xls?

    Hmm...weird, I am getting a CTD. I have all my text files in one folder, I have edited them to make sure the 9 last lines are those that I want, I run the program, I enter 9 and it crashes. Any ideas?

    Hellenic Air Force - Death, Destruction and Mayhem!

  6. #6
    Eat Meat Whale Meat
    Technical Staff Citizen Moderator Emeritus

    Join Date
    Jun 2006
    Posts
    15,812

    Default Re: Extracting data from .txt to .xls?

    Open as csv file (comma separated values).
    Remove first column.

  7. #7
    Freddie's Avatar The Voice of Reason
    Patrician

    Join Date
    Oct 2004
    Location
    UK
    Posts
    9,534

    Default Re: Extracting data from .txt to .xls?

    Quote Originally Posted by pannonian View Post
    Open as csv file (comma separated values).
    Remove first column.
    I thought of that but with the software I have installed I couldn't find a way of saving a .txt file as a .csv, no doubt a quick look in google should revel all.

  8. #8
    Friend
    Moderator Emeritus

    Join Date
    Oct 2006
    Location
    Beautiful America
    Posts
    8,626

    Default Re: Extracting data from .txt to .xls?

    @Freddie Just change the extension to .csv

    But still, that would take a long time to get the last 9 pieces of 168 thousand+ line files.

    Quote Originally Posted by Mythos View Post
    Hmm...weird, I am getting a CTD. I have all my text files in one folder, I have edited them to make sure the 9 last lines are those that I want, I run the program, I enter 9 and it crashes. Any ideas?
    You have to enter 9 ,
    that is '9', space and comma. Three characters.
    Last edited by Garnier; March 25, 2010 at 12:02 PM.


    Retired moderator of TWC
    | Under the patronage of Atterdag

  9. #9

    Default Re: Extracting data from .txt to .xls?

    I used your program and some excel-fu to do a 2h-work in 10 minutes! Thank you VERY much Garnier!!!

    Hellenic Air Force - Death, Destruction and Mayhem!

Posting Permissions

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