Parse file text file

Hi,
I like read Apache error log using external table.
For this I did create directory APACHE_LOG and grant read permission to it for my schema.
Then external table
CREATE TABLE EXT_APACHE_ERROR_LOG
    "TEXT" VARCHAR2(2000 BYTE)
  ORGANIZATION EXTERNAL
    TYPE ORACLE_LOADER DEFAULT DIRECTORY "APACHE_LOG" ACCESS PARAMETERS ( records delimited BY newline nobadfile nodiscardfile nologfile ) LOCATION ( "APACHE_LOG":'error.log' )
  REJECT LIMIT UNLIMITED;Log format is like below
[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/testI have try read file using query
SELECT REGEXP_SUBSTR(text, '[^\[]+(.*?)')      AS mesg_date,
  REGEXP_SUBSTR(text, '\[([a-z]*?)\]')         AS mesg_type,
  REGEXP_SUBSTR(text, '\[client ([0-9\.]*)\]') AS client,
  REGEXP_SUBSTR(text, '\] (.*)$')              AS mesg
FROM ext_apache_error_log;Output it is not quite what I like have as I'm bad with regexp.
I like have result in 4 columns like
MESG_DATE               MESG_TYPE     CLIENT          MESG
Wed Oct 11 14:32:52 2000     error          127.0.01     client denied by server configuration: /export/home/live/ap/htdocs/testSo I need bit help
What is best method parse that log format?
Can I have those 4 columns some way already to external table?
Thanks advance
Regards,
Jari

Hi,
I just noticed that log have lines where is no data for third column (client).
This query demonstrate situation
WITH test_data AS
  (SELECT '[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test' text
  FROM dual
  UNION ALL
  SELECT '[Wed Oct 11 14:32:52 2000] [notice] SIGUSR1 received.  Doing graceful restart' text
  FROM dual
SELECT REGEXP_replace(text, '^\[(.*?)\].*$', '\1')   AS mesg_date,
  REGEXP_SUBSTR(text, '\[(.*?)\]',1,2)               AS mesg_type,
  REGEXP_SUBSTR(text, '\[(.*?)\]',1,3)               AS client,
  REGEXP_replace(text, '^(\[.*?\]\s){3}(.*)$', '\2') AS mesg
FROM test_data ;In case there is no client info whole line from file is in fourth column (mesg).
What could be best way handle this case so that client column is null but only the message should shown in mesg column ?
Thanks advance
Regards,
Jari
Edited by: jarola on Aug 31, 2011 8:24 PM
I did come to this query
WITH test_data AS
  (SELECT '[Wed Oct 11 14:32:52 2000] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test' text
  FROM dual
  UNION ALL
  SELECT '[Wed Oct 11 14:32:52 2000] [notice] SIGUSR1 received.  Doing graceful restart' text
  FROM dual
SELECT TO_DATE(REGEXP_REPLACE(text, '^\[(.*?)\].*$', '\1'),'Dy Mon DD HH24:MI:SS YYYY', 'NLS_DATE_LANGUAGE = AMERICAN') AS mesg_date,
  REGEXP_SUBSTR(text, '\[(.*?)\]',1,2)                                                                                  AS mesg_type,
  REGEXP_SUBSTR(text, '\[(.*?)\]',1,3)                                                                                  AS client,
  REGEXP_REPLACE(REGEXP_REPLACE(text, '^(\[.*?\]\s){3}(.*)$','\2'), '^(\[.*?\]\s){2}(.*)$','\2')                        AS mesg
FROM test_data ;It seems work. If somebody have better query please post.
And also if there is in good way combine expression that remove opening bracket and closing bracket from MESG_TYPE and CLIENT columns.
Thanks

Similar Messages

  • Parse file and evaluate expressions

    Hi, I'm fairly new to Java and would be grateful for advice on the following problem:
    I have a text file containing a set of equations in the form
    -7 < a0 < 10
    9 < a1
    a0+a1 = 0...
    I need a method that can check quickly if a given array of numbers a0, a1... fulfills ALL of the conditions specified in the text file. I would like the method to parse the text file only once, and then create some temporary representation of it. I do NOT want to hard-code the set of equations in my source code.
    A time-efficient implementation is crucial for my purpose. The idea is that the text file represents a high-dimensional (10-20 dim.) space, and I would generate a random point a0, a1 ... and check if it lies in that space (i.e. fulfills ALL the conditions).
    Any suggestions would be much appreciated.

    jstmills1 wrote:
    It's actually systems biology research. I am investigating the constraints on metabolic systems (in this case, the yeast Saccharomyces cerevisiae). This yeast is capable of performing about 750 reactions between say, 500 metabolites. I'd like to toast you and your research.
    Actually, in a past life I did research that indirectly involved S. cerevisiae: I studied human polymorphisms in the alcohol and aldehyde dehydrogenase genes and how this related to alcohol-induced liver disease. Now a-days, my only experience with this bug, other than enjoying it's effects on my drinks, is to check antibodies against it in patients suspected of having Crohns disease.
    I am looking at flux distributions through that system that do not change the concentrations of the metabolites, i.e. if a metabolite is formed by reaction A and consumed by reaction B, then I am interested in the solution where the rates of A and B are equal. Also, there are lower and upper limits on the reaction rates, giving rise to inequalities a1_min < a1 < a1_max.
    I currently want to generate a set of points that lie in that solution space and correspond to functional states of that metabolic system. A representative set of points gives me an idea of how robust a particular metabolic function of that organism is. I have implemented the rest of this project in Java (visualization of fluxes through metabolic networks, generation of the constraints as given above) without worrying about processor time. Now the generation of this set of points, and checking if they lie in that space, is where processor time becomes important for me.So do you already have a solution, but are looking for a faster implementation? Or are you working from scratch on this issue?

  • Read/Parse file in PL/SQL

    How can I read and parse the text file (fixed length, csv or comma-delimited) in a PL/SQL procedure:
    987698,Kivin K Jones,10727 North Mountier Street,Potomac,MD,20854
    454678,John H Smith,58812 Normandie Farms Drive,Rockville,MD,20854
    I know I must use the UTL_FILE package. Any help would be appreciated.

    Re: UTL_FILE Examples

  • Drawing graphic component using parsed file

    hi,
    I have a problem in drawing the graphic components like rectangle,oval etc. I need to draw them on a panel after selecting a xml file from menu,parse it first, based on the contents of the parsed file the dimentions of the component should change.
    however i am able to parse the file and save the parsed contents in a separate file, but unable to draw components using its contents

    this is the module given to me where i am supposed to
    draw the graphic components using the contents of a
    xml file. I was told to parse the xml file to get
    some values that would represent parameters like
    packet size, length etc.. and using these values
    draw a data packet representation. But prob here is
    the i am able to parse file but not pass its values
    simultaneously to draw image on the panel
    immediately after parsing. i am storin the contents
    in the text format.
    ya i have good knowlege of swings,IO and awt...Parse the XML file filling a model that allows listeners (Observer/Observable is one approach). When the parsing is complete fire an event to indicate that the model has changed. Have your GUI listen to the model and when it receive the 'changed' event it updates it's display according to the content of the model.

  • Wrong result then parsing file in applet

    My applet is parsing a 3ds-file and it's working good in both applet viewer and as a stand alone application but then i try it as an applet in a browser it sometimes parses wrong.
    This is the printout i get then parsing is correct:
    Found data/model/chest.3ds in jar file.
    main chunk
    unused chunks : 2 with length: 10
    3d editor chunk
    unused chunks : 3d3e with length: 10
    unused chunks : ffffafff with length: 170
    unused chunks : 100 with length: 10
    object chunk
    Namnet p� objektet �r inl�st: Chest01
    triangular mesh chunk
    vertices list chunk
    Antalet vertices 424
    Antalet uv-koordinater 424
    unused chunks : 4160 with length: 54
    Antalet faces 168
    unused chunks : 4130 with length: 349
    unused chunks : 4150 with length: 678
    unused chunks : ffffb000 with length: 221
    This is the printout then run in an applet:
    Found data/model/chest.3ds in jar file.
    main chunk
    unused chunks : 2 with length: 10
    3d editor chunk
    unused chunks : 3d3e with length: 10
    unused chunks : ffffafff with length: 170
    unused chunks : 100 with length: 10
    object chunk
    Namnet p� objektet �r inl�st: Chest01
    triangular mesh chunk
    vertices list chunk
    Antalet vertices 424
    Antalet uv-koordinater 424
    unused chunks : ffffed3e with length: -1572921687
    unused chunks : 7856 with length: 1381233982
    This problem only occurs in some files.
    I'm parsing it by reading in the correct number of bytes and converting them to the correct type (int, char ..ect).
    Is there any difference in parsing files in a browser than in an application? The only difference I had so far is the browser beeing case sensitive in the filenames then the appletviewer isn't.
    I can post the code if you want to.
    Please help me, thanks.
    / Robert

    Ifanyone else having the same trouble I'm publishing the wrapper I used successfully.
    private static void read(InputStream in, byte[] buffer) throws IOException
            int bytesRead = 0;
            int bytesToRead = buffer.length;
            while (bytesToRead > 0)
                int read = in.read(buffer, bytesRead, bytesToRead);
                bytesRead += read;
                bytesToRead -= read;
        }

  • Does parse file change on v3.0 ?

    Hi everybody
    I tried to create parse file on 3.0 version of Apex with the same rules as old version. It didn't work.
    Before 3.0 we had
    In the page process "Parse file", it has...
    htmldb_tools.parse_file(:P1_FILENAME,'P1_COLLECTION','P1_HEADINGS','P1_COLUMNS','P1_DDL');
    And on 3.0 ? I tried
    In the page process "Parse file", it has...
    apex_tools.parse_file(:P1_FILENAME,'P1_COLLECTION','P1_HEADINGS','P1_COLUMNS','P1_DDL');
    But It didn't work
    Please follow me the right way ^^
    Regards
    Message was edited by:
    user450801

    Hi user450801,
    you have to be a little bit more patient. It's weekend!
    The htmldb_tools package is a package written by Vikas (http://htmldb.oracle.com/pls/otn/f?p=38131:1) which doesn't have to do anything with the upgrade of APEX to 3.0.
    As long as you haven't renamed your package to APEX_TOOLS it will still be accessible as HTMLDB_TOOLS.
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

  • Error parsing file

    Hi! My program compile fine and runs fine, however on the main file it has the red exclamation mark that says error parsing file. What does that mean??
    THX
    Edited by: jjcpp on Mar 3, 2010 9:55 PM

    That probably means that the JavaFX plugin isn't perfect...
    I suppose you mean you see that in NetBeans, right?
    These IDEs are powerful but sometime confused; for example from time to time Eclipse tells me a Java class (in a big Java project) doesn't exist just because it is stale (changed by VCS) and its index isn't up to date.

  • Error message when using DOMParser.parse(file)

    When I try to use the DOMParser.parse(file) to parse an invalid XML file against a XML schema, with the schema_validation feature set on, error message saying the XML file is invalid because it violates some constraints set in the schema. But I cannot find out how the error message is print. It is not caught as exception. May I know how can I detect the error in the code instead of viewing it as output?

    The error message I got is like the followings:
    [Error] abc3.xml:2:310: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '(\(\d\d\d\)-)?[\d]{8}' for type 'phoneNoType'.
    [Error] abc3.xml:2:310: cvc-type.3.1.3: The value '' of element 'mobile' is not valid.
    [Error] abc3.xml:2:318: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[^@]+@[^\.]+\..+' for type 'emailAddressType'.
    [Error] abc3.xml:2:318: cvc-type.3.1.3: The value '' of element 'email' is not v
    alid.
    May I know how can I catch these errors?

  • DNG error parsing file (Fuji S100fs)

    Windows Vista Home Premium, DNG Converter 3.7, Fuji S100fs
    I tried to convert Raw-files into DNG-files but got an error message (literally translated from German): "error parsing file".
    The Fuji S100fs has been included in the latest RAW Update so I assume the DNG-Converter should recognize the format.
    What else could be the reason?
    Thanks.
    Hans

    The problem is DNG Converter 3.7 is NOT the most recent version of the DNG Converter. You need to use the DNG Converter that is included in the latest raw update.

  • Parsing "HTML" text for AttributedString

    Well basically im writing a little instant messaging application where one user can speak to another.
    At the moment i have everything working fine, but now i want to move onto the next step. Using tags to create effects, i want to base my system on HTML since it's simple enough for people to follow and im comfortable using it.
    So anyway, im attempting to write a class which parses the text and then turns it into a java.text.AttributedString object.
    However, im stuck, i could write a class which would parse the commands (hopefully) and append the start and end of the command to the attributedstring while removing the tags as it goes along.
    But i can't think of a way to make it so that you can parse multiple commands and for example, with colour, you might have a large number or a small number so there is no definate size.
    If anyone could help me out with this i would be very gratefull and satisfied.
    Thank you for any help.

    i_own_pking wrote:
    But i can't think of a way to make it so that you can parse multiple commands and for example, with colour, you might have a large number or a small number so there is no definate size.First option that came to mind would be to split up the user's input by tags so you separate the tags from the text:
    <b><font color=red>This would be bold red font</font> whereas </b> this is <i>italicized</i>.
    Becomes:
    <b>    <font color=red>    This would be bold red font    </font>   whereas     </b>     this is    <i>    italicized    </i>    .Then you can put each segment into a tree, with each tag starting a new level in a tree (lets see if I can represent this visually):
    Root
       - <b>
          - <font color=red>
             - This would be bold red font
          - </font>
          - whereas
       - </b>
       - this is
       - <i>
          - italicized
       - </i>
       - .Then you could just do an in-order traversal of the tree, checking to see what html tag each node is, and applying it to all the leafs below that node (notice whereas is still below bold, but same level as the font, so the font color doesn't apply to it but the bold does, since it is a leaf below the node for bold).
    Edited by: bogdana on Jan 23, 2010 11:20 AM
    (messed up the grouping of the visual representation; fixed)

  • Parsing of text in JSP

    hai, I am new to java and I wanna know how can i parse a text using StringTokenizer and then add them all(integers). I tried this but doesnt work.plz help.
    <% int sum[];
    try{
    if(request.getParameter("result").indexOf("+")>=0){
    StringTokenizer st=new StringTokenizer(request.getParameter("result"), "+");
    while(st.hasMoreTokens()){
    sum=Integer.parseInt(st.nextElement());
    }}catch(Exception e){}
    %>
    appreciate ur help
    qs

    Hi
    Since you are using '+' as a delimiter my guess is that in your request URL you have gien: '?result=19+10'
    The problem with this is that the browser formats data that it sends to a server from a form in a similar fashion in that it puts a '+' for a blank space between values, So when the server interprets this it takes the '+' and inserts a blank space betweeen the values so if you provide result=8+9 then the servlet receives 8 9.....This gives you a NumberFormatException when trying to parse the Token. Instead try giving :
    http://server-name:port-number/servlet-name?result=19,10
    and in your servlet code put:
    StringTokenizer tokens = new StringTokenizer(param,",");
    This should work...
    Keep me posted on your progress.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems Inc.
    http://www.sun.com/developers/support

  • How to parse a text on a transition with OCL? is it possible ?

    Hi Everyone,
    I was just wondering if it is possible to put constraints between a transition on a state machine and a variable/attribute in a class diagram ? for example, to make sure if the user writes [X++] as a guard for a transition in state machine, the X attribute exists in the corresponding class diagram.
    Is it even possible with OCL? I think maybe it should be coded to parse the text... Any idea will be appreciated
    Thanks,
    Parsa

    Hi
    For OMG OCL, yes, since the capability is implied by the UML
    specification. However there are gaping chasms between the UML and OCL
    specifications, so any useable implementation relies on vendor intuition.
    For the new pivot-based Eclipse OCL, quite possibly. The UML support is
    primarily for Class Diagram elements, but is kind of extensible in so
    far as for unsupported UML elements, 'self' is aligned to the nearest
    containing Class. This works for statemachines, and could work for
    transitions. Activity diagrams are known to not work.
    Regards
    Ed Willink
    On 29/06/2015 18:02, Parsa Pourali wrote:
    > Hi Everyone,
    >
    > I was just wondering if it is possible to put constraints between a
    > transition on a state machine and a variable/attribute in a class
    > diagram ? for example, to make sure if the user writes [X++] as a
    > guard for a transition in state machine, the X attribute exists in the
    > corresponding class diagram.
    >
    > Is it even possible with OCL? I think maybe it should be coded to
    > parse the text... Any idea will be appreciated :)
    >
    > Thanks,
    > Parsa

  • VBScript for parsing multiple text files

    Hi,
    I have around 175 text files that contain inventory information that I am trying to parse into an Excel file. We are upgrading our Office platform from 2003 to 2010 and my boss wants to know which machines will have trouble supporting it. I found a script
    that will parse a single text file based upon ":" as the delimiter and I'm having trouble figuring out how to change it to open an entire folder of text files and write all of the data to a single Excel spreadsheet. Here is an example of the text
    file I'll be parsing. I'm interested in the "Memory and Processor Information" and "Disk Drive Information" sections mainly.
    ABEHRENS-XP Computer Inventory
    OS Information
    OS Details
    Caption: Microsoft Windows XP Professional
    Description:
    InstallDate: 20070404123855.000000-240
    Name: Microsoft Windows XP Professional|C:\WINDOWS|\Device\Harddisk0\Partition1
    Organization: Your Mom
    OSProductSuite:
    RegisteredUser: Bob
    SerialNumber: 55274-640-3763826-23029
    ServicePackMajorVersion: 3
    ServicePackMinorVersion: 0
    Version: 5.1.2600
    WindowsDirectory: C:\WINDOWS
    Memory and Processor Information
    504MB Total memory HOW CAN I PULL THIS WITHOUT ":" ALSO
    Computer Model: HP d330 uT(DG291A)
    Processor:               Intel(R) Pentium(R) 4 CPU 2.66GHz
    Disk Drive Information
    27712MB Free Disk Space ANY WAY TO PULL THIS WITHOUT ":"
    38162MB Total Disk Space
    Installed Software
    Here is the start of the script I have so far. . .
    Const ForReading = 1
    Set objDict = CreateObject("Scripting.Dictionary")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFSO.OpenTextFile("C:\Test\test.txt" ,ForReading)
    WANT THIS TO BE C:\Test
    Do Until objTextFile.AtEndOfStream
    strLine = objTextFile.ReadLine
    If Instr(strLine,":") Then
    arrSplit = Split(strLine,":") IS ":" THE BEST DELIMITER TO USE?
    strField = arrSplit(0)
    strValue = arrSplit(1)
    If Not objDict.Exists(strField) Then
    objDict.Add strField,strValue
    Else
    objDict.Item(strField) = objDict.Item(strField) & "||" & strValue
    End If
    End If
    Loop
    objTextFile.Close
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = True
    objExcel.Workbooks.Add
    intColumn = 1
    For Each strItem In objDict.Keys
    objExcel.Cells(1,intColumn) = strItem
    intColumn = intColumn + 1
    Next
    intColumn = 1
    For Each strItem In objDict.Items
    arrValues = Split(strItem,"||")
    intRow = 1
    For Each strValue In arrValues
    intRow = intRow + 1
    objExcel.Cells(intRow,intColumn) = strValue
    Next
    intColumn = intColumn + 1
    Next
    Thank you for any help.

    You are The Bomb.com! I had to play around with it to pull some additional data (model and processor) and then write a quick macro to remove the unwanted text and finally I wanted the data to write in columns instead of rows so this is what I ended up with:
    Option Explicit
    Dim objFSO, objFolder, strFolder, objFile
    Dim objReadFile, strLine, objExcel, objSheet
    Dim intCol, strExcelPath
    Const ForReading = 1
    strFolder = "c:\Test"
    strExcelPath = "c:\Test\Inventory.xlsx"
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Workbooks.Add
    Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
    intCol = 0
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strFolder)
    For Each objFile In objFolder.Files
      intCol = intCol + 1
      Set objReadFile = objFSO.OpenTextFile(objFile.Path, ForReading)
      Do Until objReadFile.AtEndOfStream
        strLine = objReadFile.ReadLine
        If (InStr(strLine, "Computer Inventory") > 0) Then
          objSheet.Cells(intCol, 1).Value = Left(strLine, InStr(strLine, "Computer Inventory") - 2)
        End If
        If (InStr(strLine, "Total memory") > 0) Then
          objSheet.Cells(intCol, 2).Value = Left(strLine, InStr(strLine, "Total memory") - 2)
        End If
        If (InStr(strLine, "Computer Model:") > 0) Then
          objSheet.Cells(intCol, 3).Value = (strLine)
        End If
        If (InStr(strLine, "Processor:") > 0) Then
          objSheet.Cells(intCol, 4).Value = (strLine)
        End If
        If (InStr(strLine, "Total Disk Space") > 0) Then
          objSheet.Cells(intCol, 5).Value = Left(strLine, InStr(strLine, "Total Disk Space") - 2)
        End If
        If (InStr(strLine, "Free Disk Space") > 0) Then
          objSheet.Cells(intCol, 6).Value = Left(strLine, InStr(strLine, "Free Disk Space") - 2)
        End If
      Loop
    Next
    objExcel.ActiveWorkbook.SaveAs strExcelPath
    objExcel.ActiveWorkbook.Close
    objExcel.Quit
    Thanks again!
    Hi ,
    I am have very basic knowledge about VB scripting, but this code could be the perfect solution i am looking for. could you guide me exactly how to run and test the same , i would be really thankful for your kind and generous support on this.
    Thanks ,
    Veer

  • Using a scanner to parse a text file

    Hi,
    I'm running into some difficulties using a pattern for my scanner (java.util.Scanner). I need to scan a text file which consists of records. Each record has a keyword and a value (like property files):
    Example:
    FACILITY=TEST
    LOT=1234567
    DEVICE=abcdefgNormally, every record will be ended by a carriage return and line feed. So what I did was using a scanner with cr/lf as delimiter. That worked fine for most records but there are some records which span several lines (with cr/lf at the end of each line), e.g.:
    MAP_XY.01.01=" Y-7 24/10 Y-6 24 22/17 15/7 Y-5 29/7 5 Y-4 32/22 20
    19/15 13/4 Y-3 34/24 22/13 11/2 Y-2 36/30 28/24 22
    21/12 10/4 2/0 Y-1 38/0 Y0 40/35 33/22 20/15 13/0 Y1 41
    40/32 30/8 6/-1 Y2 42/26 24/-2 Y3 42/-5 Y4 47/11 9
    8/3 1/-6 Y5 48/47 45/39 37/18 16/-7 Y6 49/8 6/-8 Y7 49
    47/8 6/4 2/-8 Y8 50/9 7/3 1/-9 Y9 51/11 9/-10 Y10 51
    50/33 31/-10 Y11 52/40 38/35 33/23 21/16 14/-11 Y12 52
    51/34 32/15 13/4 2/-11 Y13 53/40 38/35 33/-12 Y14 53
    52/35 33/27 25/18 16/13 11/9 7 5 2/0 -4/-12 Y15 53
    52/-12 Y16 53/22 20/-5 -7/-13 Y17 54/47 45/-7 -9/-13 Y18 54
    53/22 20 18/2 0/-13 Y19 55/16 14/13 11/-2 -4/-13 Y20 55
    53/41 39/35 33/-14 Y21 55/52 50/48 46/16 14/10 8/-2 -4
    -6/-14 Y22 54/33 31/7 5/4 2/0 -2/-9 -11/-13 Y23 55
    54/53 51/26 24/-2 -4/-13 Y24 55/15 13/-14 Y25 55 53
    52/-7 -9/-10 -12/-14 Y26 54/44 42/14 12/10 8/-4 -6
    -7/-10 -12/-13 Y27 55/52 50/23 20/16 14/-13 Y28 54
    53/12 10/-1 -3/-13 Y29 55/44 42/-13 Y30 55/15 13/10 8
    7/-13 Y31 55/17 15/-13 Y32 54/44 42/-1 -3/-13 Y33 54
    53/41 39/30 28/-13 Y34 54 52/37 35/19 17/12 9/8 5/3 1
    0/-4 -6 -9/-11 Y35 54/-13 Y36 54/35 33/31 29/13 11
    10/2 0/-2 -4/-13 Y37 54/-13 Y38 53/11 9/0 -2/-9 -11
    -12 Y39 53/35 33/31 29/-12 Y40 53/22 20/15 13/-12 Y41 52
    50/15 13/10 8/-11 Y42 52/11 9/5 3/-6 -8/-11 Y43 51
    50/41 39/10 8/0 -2/-10 Y44 51/28 26 24/15 13/12 10
    9/-10 Y45 50/43 41/32 30/4 2/-9 Y46 49/31 29/13 11
    10/-8 Y47 49/47 45/30 28/24 22/-8 Y48 48/42 40 38/12 10
    9/-7 Y49 47/42 40/38 36/-6 Y50 44/33 31/30 28/6 4/-5 Y51 44
    43/28 26/17 15/13 11/-2 Y52 44/32 30/-2 Y53 43/32 30
    29/13 11/-2 Y54 42/27 25/24 22/16 9 7/-1 Y55 41/21 19
    18/0 Y56 39/15 13/6 4 2 Y57 38/20 18/3 Y58 36/5 Y59 34
    33 31/30 28/7 Y60 31/28 26/10 Y61 27/14"
    BIN_COUNT.01.09=12345Using the following delimiter does not work
    fileScanner.useDelimiter("\\s*=\\s*");because the result would be something like:
    keyword: FACILITY     value: TEST
    LOTkeyword: 1234567
    DEVICE     value: abcdefgWhat I need is a pattern which also handles carriage return/line feed until a new keyword (like LOT for example) occurs.
    The correct result should be:
    keyword: FACILITY     value: TEST
    keyword: LOT            value: 1234567
    keyword: DEVICE     value: abcdefg
    keyword: MAP_XY.01.01 value: " Y-7 24/10 Y-6 24 22/17 15/7 Y-5 29/7 5 Y-4 32/22 20...
    {code}
    I hope, I did explain clearly enough...
    Any help would be appreciated.
    Thanks and best regards
    - Stephan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Any help would be appreciated.You have grouping and data in the groupings and you are attempting to parse it all at one go.
    Won't work. (Might in a perfect world but not in this one.)
    You need a parsers that do the following
    1. Parser text file (stream) into records.
    2. Parse records into data.
    You can put both into one class or not.
    Your record parser is going to be based roughly on the following scheme.
    1. Find keyword,
    2. Look up format defined for keyword
    3. Attempt to read format found.
    4. Error if format not found.
    5. Else return the record found.
    I say roughly because as noted above you need to know what the actual output looks like. It is possible to determine this if you have enough examples but it is a lot easier if you actually get the specification that tells you what it looks like.
    I suspect, but don't know that the "format" in the above will consist of the following.
    <word><text>
    or
    <word><text>
    <space><text>
    <space><text>
    You could just create one format for the all but you will likely have record types that don't fit that and the earlier you detect errors the better.

  • Parsing a Text file with nulls in records

    Hello All,
    I am relatively new to Java programming and I have been given a task that requires me to parse a CSV text file. I have to group the records based on a particular column and then do some math (add columns that have same keys). My problem is that the input file can have nulls and non numeric chars. I am confused how I can proceed in this situation, since I have to add these records, when I do a parseDouble it might fail. OK. I can get around it by assigning a zero in case there is a NumberFormatException but the result of my task is to render an output text file that from the input file. Here comes the catch, the requirement has it, that if the input file had a null or a non numeric char then while rendering the output, I have to populate a code as a place holder for that location where a null or non numeric char was found. I'd like to know if there is any trivial way of getting around this problem without using a Map to remember the location where the null was found. Any help is greatly appreciated. Thanks all in advance.

    maybemedic wrote:
    Mogalr,
    The non numeric chars could be any random chars like aabb,null strings etc.In the past I've made small methods that would just check to see if the string was all characters and decimal point... and check formatting... check that it doesn't have 2 decimal points and after it's trimmed that there aren't any spaces and the length is >0.
    The checking is slower than using like Double.doubleValue(), unless you hit a format exception. So you have to decide what quality of data you have before committing to you're game plan.

Maybe you are looking for