Count number of times each char appears??

Hi! I'm trying to figure out, how to count the number of times ech character appears in the text using ascii code??

Go the text character-by-character, and count each character. It's that simple.
The only remotely hard part is holding your character counters. You could use a Map.
But if you know that the characters are always going to be ASCII, then there's only going to be 128 of them.
So an array of int with 128 elements should be sufficient.
Those are more than enough hints. Go do your homework now.

Similar Messages

  • QUERY WHICH COUNTS NUMBER OF TIMES WORDS/LETTER APPEAR IN SENTENCE - Thanks

    I have this query below
    it gives the number of times a txn is hign comfort and Approved
    .. nyumber of times txn is meduim comfort and approved etc.
    There is a futher line whihc shows the number of times txn is blacklisted BL COUNT.
    I am trying to get line of query which can show me the number of times txn is approved, is high comfort and blcklisted ( the same applies for
    wl - watch listed)
    The query i am using
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('BL(%') and cc.Comment
    LIKE ('Approved%')
    AND cc.Comment
    LIKE ('%ComfortLevel=High Comfort%')
     THEN 1
    ELSE 0 END)AS hbcl  - NO RESULTS BEING GIVEN
    pLEASE CAN ANYONE HELP,. THANKS
    QUERY
    USE RiskManagementReporting
    GO
    DECLARE
    @StartDate DATETIME,
    @EndDate DATETIME
    SET @StartDate
    = '2014-01-01 00:00:00'
    SET @EndDate
    = '2014-03-31 23:59:59'
    SELECT
    CONVERT
    (VARCHAR(10),
    mt.OPacket_TransactionTime, 102)
    AS [Date],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Approved%')
    AND cc.Comment
    LIKE ('%ComfortLevel=High Comfort%')
    THEN 1 ELSE 0
    END) AS [A - HighC],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Approved%')
    AND cc.Comment
    LIKE ('%ComfortLevel=Medium Comfort%')
    THEN 1 ELSE 0
    END) AS [A - MediumC],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Approved%')
    AND cc.Comment
    LIKE ('%ComfortLevel=Low Comfort%')
    THEN 1 ELSE 0
    END) AS [A - LowC],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Declined%')
    AND cc.Comment
    LIKE ('%ComfortLevel=Low Risk%')
    THEN 1 ELSE 0
    END) AS [D - LowR],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Declined%')
    AND cc.Comment
    LIKE ('%ComfortLevel=Medium Risk%')
    THEN 1 ELSE 0
    END) AS [D - MediumR],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Declined%')
    AND cc.Comment
    LIKE ('%ComfortLevel=High Risk%')
    THEN 1 ELSE 0
    END) AS [D - HighR],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('BL(%')
    THEN 1 ELSE 0
    END) AS [BL Count],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('WL(%')
    THEN 1 ELSE 0
    END) AS [WL Count],
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Marked as Touched%')
    THEN 1 ELSE 0
    END) AS [Touched by DRT],
    COUNT
    (mt.csnTransactionId)
    AS [Sent to DRT]
    FROM MatchedTransaction mt
    WITH (NOLOCK)
    LEFT
    JOIN CustomerComment cc
    WITH (NOLOCK)
    ON (mt.csnTransactionId
    = cc.SenderMTCN
    AND cc.InsertDate
    BETWEEN @StartDate AND
    DATEADD (D, 1, @EndDate)

    I have adjusted this as  
    SUM
    (CASE
    WHEN cc.Comment
    LIKE ('Approved%')
    AND cc.Comment
    LIKE ('%ComfortLevel=High Comfort%')
    AND cc.Comment
    LIKE ('%BL(%')THEN 1
    ELSE 0 END)
    AS hcbl,
    Still no result

  • How do I count the number of times a word appears in a column?

    What I have is a spreadsheet logging work history. Let's say the work location is "office", "home", or "travel" and I want to have a separate cell in another table for totals, count up the number of time each appears in the data for the year. So it would look like this:
    Date
    Location
    sept 1
    office
    sept 2
    home
    sept 3
    home
    sept 4
    travel
    sept 5
    office
    sept 6
    office
    sept 7
    office
    sept 8
    travel
    sept 9
    home
    sept 10
    office
    Totals
    Days
    10
    Office
    5
    Home
    3
    Travel
    2
    I just can't figure out how to develop the formula to put in the Totals column to make it work this way. If you can help me achieve this I'd really appreciate it!

    Hi SpartanAntarctican,
    Table 1 to record your locations
    Date
    Location
    sept 1
    office
    sept 2
    home
    sept 3
    home
    sept 4
    travel
    sept 5
    office
    sept 6
    office
    sept 7
    office
    sept 8
    travel
    sept 9
    home
    sept 10
    office
    Table 2 to sum your locations
    Totals
    Days
    10
    Office
    5
    Home
    3
    Travel
    2
    In Table 2 the formula in B2
    =ROWS(Table 1::A)−1
    Minus 1 because there is a Header Row in Table 1.
    In Table 2 the formula in B3 (and Fill Down)
    =COUNTIF(Table 1::B,A3)
    You can check this by adding 5 + 3 + 2 to arrive at 10
    Or maybe delete Row 2 put the Days calculation into a Footer Row in Table 2
    =SUM(B) .
    Regards,
    Ian.

  • Find the Number of times a '¯'character appears in a string.

    Hi,
    In my staging table I am having data like below
    ABL¯ABL¯0¯0¯ABL¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ 
    ABL¯ABQ¯480¯825¯DLS¯AMA¯ABQ¯ ¯ ¯ ¯ ¯ ¯ ¯ 
    ABL¯ACD¯808¯1255¯DLS¯ELP¯TCS¯PHX¯ACD¯ ¯ ¯ ¯ ¯ 
    ABL¯ADE¯1256¯471¯DLS¯AMA¯ABQ¯LSV¯ADE¯ ¯ ¯ ¯ ¯ 
    ABL¯AFT¯1140¯1744¯DLS¯LAX¯FON¯AFT¯ ¯ ¯ ¯ ¯ ¯ 
    ABL¯AHM¯1178¯1637¯DLS¯LAX¯AHM¯ ¯ ¯ ¯ ¯ ¯ ¯ 
    ABL¯ALB¯1769¯1825¯DLS¯WIL¯ALB¯ ¯ ¯ ¯ ¯ ¯ ¯ 
    ABL¯ALE¯1041¯1150¯DLS¯ALE¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯
    Now I want to find the Number of times a '¯'character appears in a string.
    I should get output 14
    thanks & regards,
    Vipin Jha
    Thankx & regards, Vipin jha MCP

    Hi Vipin,
    You can try below sql code also
    code:-  len(data)-len(replace(data,'¯','')) -(len(data)-len(replace(data,' ','')))
    select data,len(data)-len(replace(data,'¯','')) -(len(data)-len(replace(data,' ',''))) CountofCharacter from
    select 'ABL¯ABL¯0¯0¯ABL¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ' data
    UNION
    SELECT 'ABL¯ABQ¯480¯825¯DLS¯AMA¯ABQ¯ ¯ ¯ ¯ ¯ ¯ ¯ '
    UNION
    SELECT 'ABL¯ACD¯808¯1255¯DLS¯ELP¯TCS¯PHX¯ACD¯ ¯ ¯ ¯ ¯ '
    UNION
    SELECT 'ABL¯ADE¯1256¯471¯DLS¯AMA¯ABQ¯LSV¯ADE¯ ¯ ¯ ¯ ¯ '
    UNION
    SELECT 'ABL¯AFT¯1140¯1744¯DLS¯LAX¯FON¯AFT¯ ¯ ¯ ¯ ¯ ¯ '
    UNION
    SELECT 'ABL¯AHM¯1178¯1637¯DLS¯LAX¯AHM¯ ¯ ¯ ¯ ¯ ¯ ¯ '
    UNION
    SELECT 'ABL¯ALB¯1769¯1825¯DLS¯WIL¯ALB¯ ¯ ¯ ¯ ¯ ¯ ¯ '
    UNION
    SELECT 'ABL¯ALE¯1041¯1150¯DLS¯ALE¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯'
    ) t
    Thanks
    Prasad

  • Calculate number of times a name appears within a date range.

    Hello,
    I am actually using the iPad version but I assume the formula will be the same. Say I have a date in column A and a list of names in column B. What would the formula be to calculate the number of times a specific name appears in a date range.
    Thank you

    If C2 = the minimum date of the range
    C3= the maximum date of the range
    and you are looking for John as the name
    =COUNTIFS($A,">="&C2,$A,"<="&C3,B,"john")
    which counts cells where A>=the min date and A<=the max date and B="john"

  • Count number of times an instructor has taught a class

    Howdy Folks, I'm using a lifeline to see if i can get some help for a question. I apologoze in advance, i know this is a numbers forum, but i am working with an excel spreadsheet and was hopng someone could give me a push in the right direction. i want to count how many times an instructor has taught a class based on dates. The spreadsheet is filled out via an applescript so the instructor's name appears with every student. I've been trying to use the count if formula in excel but i cant make it work. any suggestions? it should count james as 2 since he taught classes on two different dates, and nub as 1. all information is fictional and used for demo pruposes.

    This will work for you... I hope:
    I had to add three columns to your existing table, then crete a second table (on the right) to summarize:
    The three columns can be anywhere but I added then right after column G
    The table on the right in this example will have to be a new sheet in excel.  On a mac Numbers is free (If you have Mavericks) so maybe you want to try to download from the App store.
    H2=IF(COUNTIF( $H$1:H1, F2&"-"&E2)=0, F2&"-"&E2, "")
    this is shorthand for... select cell H2, then type (or copy and paste from here) the formula:
    =IF(COUNTIF( $H$1:H1, F2&"-"&E2)=0, F2&"-"&E2, "")
    I2=IF(H2="", "", MAX($I$1:I1)+1)
    J2=IF(COUNTIF($F$1:F1,F2)>0, "", MAX($J$1:J1)+1)
    select H2 thru J2, copy
    select H2 thru the end of  column J
    paste
    In the new table (for Numbers) or sheet(in excel):
    A2=IF((ROW()−2)<MAX(Table 2::J), OFFSET(Table 2::$F$2,MATCH(ROW()−1, Table 2::J,0), 0),"")
    B2=IF(A2≠"", COUNTIFS(Table 2::F, A2, Table 2::I, ">0"), "")
    select A2 and B2, copy
    fill down as needed

  • Calculate the number of times a character appears in a string

    Please help.
    Is there a way to count a number of occurences of a particular character in a string? e.g. If you have 'DATABASE' as a string, can you calculate the number of times 'A' occurs in it? The answer is supposed to be 3, but can you calculate it in Oracle?
    Thanks in advance.

    Re: Any built-ins for occurance

  • Count number of times a specific element occurs in ArrayList

    I need to count the number of times a specific element occurs in an ArrayList. For example, if an ArrayList 'overflow' consists of the following elements:
    1,3,4,1,1,8,14,7,3,7,8,0.
    I need to count the number of times 4 occurs in the list.
    ArrayList overflow = new ArrayList();
    if(overflow.contains(4))
    }I know that contains returns true if 4 exists in the ArrayList, but how do I count the number of times 4 occurs? Any help will be appreciated. Thank you.

    There is the Collections.frequency method in j2se 1.5
    Or you could loop through the values in the ArrayList and count the number of times it occurs.

  • Find the number of times a word appears

    In Google Chrome find/search (ctrl+F) it will tell you how many times the word you are finding appears.
    In Firefox I know you can find things (also ctrl+F) but is there any way in which you can find how many times that word appears, like in Chrome.

    Any help please, anyone?

  • Count Number of Times an App ls Launched/Used

    Anyone know if there's an app and/or API or something that would let you know how many times another application-- or actually all other applications-- were either (a) launched (first time) and (b) brought to the foreground (used more than once)? I did a forum search here and couldn't find any reference, and maybe it's more of a developer question, just thought someone might have heard of an existing app that already does something like it or know if there's an existing API call that would allow it. Thx KV

    James should show 2 classes and nub should show 1 class. sorry

  • Need to count the number of times the Basic Finish data chages

    HI Expertes,
    I have a requirement I need to count number of times the Basic finish date chaged for PM work order. I went throug our forums I got some info like using a standard function module
    CHANGEDOCUMENT_READ_HDRS_ONLY
    CHANGEDOCUMENT_READ_HEADERS
    CHANGEDOCUMENT_READ_POSITIONS
    But all the above function module will not be suitable for my requirement since  CHANGEDOCUMENT_READ_HDRS_ONLY it gives whole changes but my requirement is just need number of changes occurred in Basic Finish date but CHANGEDOCUMENT_READ_POSITIONS can give the filed number which has been changed but still I need change id.
    So kindly suggest me wether there is any other Standard FM to get number of changes occurred in Basic Finish date?
    Thanks,
    Rajesh

    Hi Debbie,
         To count the number of groups please try the folling steps:
    1) Create a formula @reset and place this formula in the page header
        whileprintingrecords;
        numbervar i:=0;
    2) Create another formula @evalgroup place this in the group header where you want to count the values.
        whileprintingrecords;
        numbervar i:= i+1;
    3) Create another formula @display and place this in report footer.
        whileprintingrecords;
        numbervar i;
    In order to display the count of details which are printing in the detail section place the eval formula in the detail section and the @display formula in the group footer.
    Hope this helps!!!
    Regards,
    Vinay

  • Counting times a word appears in document

    I am trying to read from a file and count how many times a word appears in that document.
    For example if i had a list of names
    Daniel Fowler
    Joe Mahogony
    Daniel Peterson
    Chris Sim
    How would you count the amount of people named Daniel and display it?
    I am currently using findInLine"Daniel" but when ran no luck.
    Any ideas?

    danieltnbaker wrote:
    deepak,
    the bufferedreader reads content from the file yes?
    but what method would i use to count the amount of a word in that file?
    finInLine finds the word but cannot turn that into an integer. any other methods?first of all the code I had posted in my previous post should work and it uses the Scanner to read the file.
    If you want to use the FileReader approach the within the code that actually reads the file line by line, you can use the String.indexOf method (as suggested by nclow) to check if a particular word is present in that line of the file. IF it is there you increment a counter.
    int counter = 0;
    // Read through the entire file
    String currentLineFromFile = bufferedReader.readLine(); // throws IOException
    while(currentLineFromFile != null)
        // Add a carriage return (line break) to preserve the file formatting.
        textFromFile.append(carriageReturn + currentLineFromFile);
        currentLineFromFile = bufferedReader.readLine(); // throws IOException
          if (currentLineFromFile.indexOf("Daniel") != -1)
                counter++
          System.out.println("No of occurances- " + counter);
    }hope this helps
    [email protected]
    Edited by: deepak_1your.com on 16-Apr-2008 14:18

  • Generate numbers in incremental order, the number of times condition met?

    I have tried explaining my problem here also.
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=31&t=007531&p=1
    But trying to put in other words now.
    I have a NO tag which appears many times in xml. and alwyas have some random numbers displaying.
    output looks something similar to this
    something......<NO>1</NO>
    something......<NO>1</NO>
    something......<NO>2</NO>
    something......<NO>1</NO>
    something......<NO>3</NO>
    something......<NO>1</NO>
    something......<NO>5</NO>
    something......<NO>1</NO>
    something......<NO>1</NO>
    something...... & so on.
    Now instead of these numbers coming in this order i prefer to display in final output file as
    1 2 3 4 5 .................... n
    Is it possible in any ways using xslt.
    DO we need to ignore the values given in input file and then generate output values for same.
    it can be like the number of times NO tag appears in xml, it should start from 1 and keep increasing value by 1, until NO tag finishes appearance.
    But next time when other xml transforms it again should be able to start from 1 till n.
    is there a possibility of using java code for this situation or xslt is capaable enough to handle this.
    Thanks
    VJ

    I'm guessing you are looking for something like this. I used a pull approach but it could be done with a push (xsl:for-each).
    Sample XML
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
         <NO>1</NO>
         <NO>1</NO>
         <NO>2</NO>
         <NO>1</NO>
         <NO>3</NO>
         <NO>1</NO>
         <NO>5</NO>
         <NO>1</NO>
         <NO>1</NO>
    </root>
    Sample XSLT
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:output method="xml" version="1.0" omit-xml-declaration="yes" encoding="UTF-8" indent="yes"/>
         <xsl:template match="root">
              <output>
                   <xsl:apply-templates select="NO"/>
              </output>
         </xsl:template>
         <xsl:template match="NO">
              <row>
                   <xsl:value-of select="position()"/>
              </row>
         </xsl:template>
    </xsl:stylesheet>
    Sample Output
    <output>
         <row>1</row>
         <row>2</row>
         <row>3</row>
         <row>4</row>
         <row>5</row>
         <row>6</row>
         <row>7</row>
         <row>8</row>
         <row>9</row>
    </output>

  • How to calculate the number of times an user has accesed a BEx report

    Hi Experts,
    We have number of reports in our BW portal and users logon to the portal and run the reports.
    How do we count the number of times each user has logged in and ran each report.
    Kindly advice.
    Thanks,
    Sai

    Hi Sai:
    I think you can use BI statistics information, which could provide you more detail information.
    You can follow the document
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/90080703-4331-2a10-cd98-9c1e95acdea0
    Regards,
    Louis Lu

  • Hey! On excel I want to count how many time a text come back in the spreadshit (sum) thx, hey! On excel I want to count how many time a text come back in the spreadshit (sum) thx

    Excel:
    line of cellule with 3 different text. I want to count have many time a text come in the line... Thx for helping me, it is for my job!!

    Hopefully I am understanding your question.
    A typical way to count how many times a word appears in a line of text in a cell is to substitute spaces for the word, one less space than the length of the word. Example:
    A1 has the string "brown red brown green"
    A2 =LEN(A1) - LEN(SUBSTITUTE(A1,"brown","    "))  
    "brown" has five letters so there are four spaces in the substitution text)
    If you want to do several cells at once, counting the total number of times the word appears, concatenate the cells with a space between them
    A1 and A2 have text in them
    A3 =LEN(A1&" "&A2) - LEN(SUBSTITUTE(A1&" "&A2,"brown","    "))

Maybe you are looking for