Results 1 to 8 of 8
  1. #1
    breitbc is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default Looking for a Text Parser

    I have a large text file and I need to identify if any of the lines have more than 14 quotations.

    Here is an example of a line:
    "00000099"|"00009999"|"WCD 0000000000"|1794.00|"Work Comp "|"GROUNDS SERVICES "|"2011-04-07"|"N"

    and

    "00000099"|"00009999"|"BPF 0000000000"|1287.00|"Commercial "|"ALFAHEL, JOHNSON "ANDY" - DBA "|"2011-04-07"|"N"

    The first line has 14 quotations and the second has 16 quotations. I need it to pull out or identify any line that is greater than 14.

    Does anyone have any recommendations on how to do this or which software would be best. I tried text template parser but that does not seem to be what I'm looking for.

    I'm not a programmer, just a simple business analyst trying to not have to manually search through 50k plus lines every month.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by breitbc View Post
    I have a large text file and I need to identify if any of the lines have more than 14 quotations.

    Here is an example of a line:
    "00000099"|"00009999"|"WCD 0000000000"|1794.00|"Work Comp "|"GROUNDS SERVICES "|"2011-04-07"|"N"

    and

    "00000099"|"00009999"|"BPF 0000000000"|1287.00|"Commercial "|"ALFAHEL, JOHNSON "ANDY" - DBA "|"2011-04-07"|"N"

    The first line has 14 quotations and the second has 16 quotations. I need it to pull out or identify any line that is greater than 14.

    Does anyone have any recommendations on how to do this or which software would be best. I tried text template parser but that does not seem to be what I'm looking for.

    I'm not a programmer, just a simple business analyst trying to not have to manually search through 50k plus lines every month.
    If by 'quotations' you mean 'quote characters' the solution is simple:

    Java Code:
    String line= ...;
    int quotes= line.replaceAll("[^\"]", "").length();
    The code snippet above removes every character that is not a quote from the 'line' String. The number of remaining characters are all quotes.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    Replace all characters other than quotes and check the length of the returned String.
    Java Code:
    line.replaceAll("[^\"]", "").length()
    There could be several variations on this technique, such as splitting the string with an appropriate regex and determining the length of the returned array.

    db

    edit Grrrr, came in second by seconds!
    Last edited by DarrylBurke; 05-10-2011 at 06:34 PM.

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    From a programming perspective, you could also readily parse this information with a simple program/script (read the file, split each line of the file on the quote, then count the resulting array length - edit: the above folks beat me to the punch with this solution)

    A tool like awk could also help you parse this information (it runs on unix and linux, but I believe there is a windows version as well). Depending upon how familiar you are with programming and/or command line processing, the initial learning curve could be easy or not so easy.
    Last edited by doWhile; 05-10-2011 at 06:34 PM.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by DarrylBurke View Post
    Replace all characters other than quotes and check the length of the returned String.
    Java Code:
    line.replaceAll("[^\"]", "").length()
    There could be several variations on this technique, such as splitting the string with an appropriate regex and determining the length of the returned array.
    You weren't peeking over my shoulder were you? ;-)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    Quote Originally Posted by JosAH View Post
    You weren't peeking over my shoulder were you? ;-)

    kind regards,

    Jos
    No, but I suspect you peeked over mine in time to replace replace with replaceAll ;)

    db

  7. #7
    breitbc is offline Member
    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Default

    Thanks guys I will give that a try!

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by DarrylBurke View Post
    No, but I suspect you peeked over mine in time to replace replace with replaceAll ;)
    Mwah, I fell asleep with my nose on the keyboard and you known what can happen then ... ;-)

    kind regards,

    Jos (<-- sincerely hates those regular expressions)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Custom Text Parser
    By magnum99 in forum New To Java
    Replies: 4
    Last Post: 07-11-2009, 12:15 AM
  2. Replies: 0
    Last Post: 07-07-2009, 06:22 AM
  3. [SOLVED] Text Parser
    By karthik7974 in forum New To Java
    Replies: 20
    Last Post: 04-22-2008, 10:18 AM
  4. DNS name parser 1.2.1
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 07-14-2007, 08:21 PM
  5. XML Parser
    By samfuerte in forum XML
    Replies: 1
    Last Post: 07-14-2007, 04:14 PM

Posting Permissions

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