Results 1 to 4 of 4

Thread: Text parsing

  1. #1
    Join Date
    Mar 2011
    Posts
    2

    question Text parsing

    I have a number of log files that I have to search for specific text. The information I need is spread over a couple of lines. For example:

    Guest entry ID# 1447
    <<unimportant line of text, variable in length>>
    At 37/67

    I am looking to gather the ID#, as well as the text following "At" on the third line.

    I would like to export the information into a .csv file.

    So far, the script that I have used is as follows (returning only the filename and ID#):

    echo."Header 1","Header 2" > output.csv
    ( for %%a in (*.0*) do (for /f "tokens=5*" %%B in ('find "Guest entry " ^< %%a') do (echo."%%a",%%B,%%C))) >> output.csv
    start "" output.csv

    advTHANKSance

  2. #2
    Join Date
    May 2009
    Posts
    529

    Re: Text parsing

    I an not sure about the issue but there is something which can help you. You can look below the thread link which has a similar solution. Second thing Text::CSV. This provides you support for composition and decomposition of comma-separated values. This class is enough capable of combing files in a CSV string and then parse the CSV string to an field.

    script to extract data from text file and put into excel format

  3. #3
    Join Date
    Mar 2011
    Posts
    2

    Re: Text parsing

    I'm not sure that hauling the text into Excel will work for these text files. To be honest, it is in support of a play-by-email game.

    There is a lot of other information in the file, and the spacing of the text I want is not consistent throughout the files that I want to search through.

    I am tempted to just get a virtual machine up and running with Linux so I can grep it, but that involves a lot of learning too, so I want to ensure that I have explored all the 'easy' Windows options first.

  4. #4
    Join Date
    Dec 2007
    Posts
    1,736

    Re: Text parsing

    I suggest always using the Import Text Wizard when opening any text file in Excel. It guides you to define how the file should be parced and the data type of each field/column. From the drop down menu, click
    Code:
    Data/Get External Data/Import Text File
    and follow the wizard. My experience is that its a lot easier to define it up front than "fix" it after opening. The above is not code, but drop down menu navigation.

Similar Threads

  1. How to use XML Parsing using PHP
    By LasitMalinga in forum Software Development
    Replies: 4
    Last Post: 05-10-2011, 02:33 PM
  2. Parsing XML in Objective C
    By Sheravat in forum Software Development
    Replies: 4
    Last Post: 29-05-2010, 05:58 AM
  3. VBScript for parsing multiple text files
    By mytorchedsoul in forum Software Development
    Replies: 1
    Last Post: 23-04-2010, 09:29 PM
  4. javafx xml parsing example
    By russ_da_buss in forum Software Development
    Replies: 3
    Last Post: 10-08-2009, 06:56 PM
  5. Parsing in C++
    By Elijah in forum Software Development
    Replies: 4
    Last Post: 20-04-2009, 11:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,573,065.64063 seconds with 16 queries