Counting words, lines and char
i want a program which counts the number of lines,words and characters in a file.....................
please help me
One thread is enough.Continue there, please.
[http://forums.sun.com/thread.jspa?threadID=5367866]
I'm locking this one.
Similar Messages
-
Count word appearance and show in gridview
Hello all, I am working on a project with multi tables. In one table the user selects one of 13 categories that they are uploading images to. Each category has a sub category. On the main page , I have a grid view for each category that list the subcategories.
Much the way a classified ads would work, I want to be able to show the number of each image in the subcategories as in below.
Name
number
of images
Subcategory
3
Subcategory
2
Subcategory
4
Subcategory
23
Subcategory
1
Subcategory
3
Subcategory
332
Subcategory
1
Subcategory
3
Subcategory
2
Subcategory
3
I am using the count function in stored procedure that counts the number of images in subcategory entered
select subcategory, count(*) as mycount from userinput group as subcategory.
which gives me the count of each item under the subcategory listed by the user.
I need to be able to take this count and show it next the item name in the 13 tables that list the subcategories.
So I am counting the entries from one table (datasource) and showing the number of entries in 13 different tables (GridViews) based on the name of the subcategory.
this has to be done when the page loads so the usre will see the correct amount of images in the 13 grid views.
Any ideas on how to do this??
Thanks in advance.Hi Jasonpauthement,
If I understand correctly, you want to display the categories and corresponding subcategories in the main table, then display the each subcategory and the corresponding count images in another 13 tables. If in this scenario, we can refer to the steps below
to display another 13 tables:
Drag a table with subcategory and the corresponding count images values to the design surface.
Then use a list with the same dataset to contain the table.
In Row Groups, Right-click the Details group to add a group grouped on subcategory.
Then each subcategory and its corresponding count images values would be displayed in the list. If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Help with program using hashtable to count words & other chars in txt file
I need to use only a hashtable to count the occurences words and chars in a text file and display them alphabetically. I am not to use anything but the hashtable. so far, I can get it to count only the words in the file and not the chars, I want to know how to make it count the chars (,.;:?(){}[]!@#$%^&\t\"<>/`~ ) that may be found and if it is possible to get it to display them in a sorted (alphabetical) order w/o using anything else.
This is what I have: mport java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
class words{
String word;
int count;
public class WordCount{
static Hashtable h=new Hashtable();
static words w;
static void countWords(String s){
if((w=(words)h.get((java.lang.Object)s))==null){
w=new words();
w.word=s;
w.count=1;
h.put(s,w);
}else{
w.count++;
h.remove(s);
h.put(s,w);
public static void main(String args[]){
String s;
StringTokenizer st;
String t;
String fn = JOptionPane.showInputDialog("Enter the filename:");
BufferedReader br = null;
try{
br = new BufferedReader(new FileReader(fn));
s=br.readLine();
while(s!=null){
st= new StringTokenizer(s, " ,.;:?(){}[]!@#$%^&\t\"<>/`~ ");
// Split your words.
while(st.hasMoreTokens()){
t=st.nextToken();
countWords(t);
s=br.readLine();
}catch(Exception e){
e.printStackTrace();
Enumeration e=h.elements();
w=(words)e.nextElement();
while(e.hasMoreElements()){
System.out.println(w.word + " " + w.count);
w=(words)e.nextElement();
System.exit(0);
}Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.
-
Link between Delivery schedule line counter from PO and the material docume
Dear Gurus,
I have one PO with single line item having delivery schedule -
Material 1 -
delivery schedule 01.01.2009 2000
01.03.2009 5000
I have received quantity against this Po
I want to know where I can find the link between Delivery schedule line counter from PO and the material document
Best regards
SarThere is no link from the MAterial document line item (Table Mseg) to the PO Schedule Line (EKET).
If this is for Evaluating an on time delivery or GR, you may consider the following approach.
PO details Po Date QTY
Sch1 01Jun2009 200
SCH2 08Jun2009 100
GR Details
GR1 01Jun2009 180
GR2 07Jun2009 110
GR3 09Jun2009 10
Calculate a *** total qty for the PO Line.
PO details Po Date CUMUL QTY
Sch1 01Jun2009 200
SCH2 08Jun2009 300
Calculate a *** total qty for the ontime GR.
PO details Po Date CUMUL PO QTY CUMUL GR on time
Sch1 01Jun2009 200 180
SCH2 08Jun2009 300 290 (180+110) the 3rd GR was too late
Evaluate the PO SChedule Lines as follows:
Po SCL qty + CUMUL GR QTY - CUMUL PO QTY = ADJ GR ON Time Qty
SCH1 01Jun2009
200 + 180 - 200 = 180 on time for 01Jun2009 date ( 90% fill rate)
SCH2 08Jun2009
100 + 290 - 300 = 90 on time for 08Jun2009 date (90 % fill rate) the first 20 of the GR on 07Jun2009 went to fill the late, early date.
Best of luck !
SCH2 100 +290 - 300 = 90 on time for 07Jun2009 date -
I created a word document with hyperlinks. When my default browser is Chrome the hyper links work. When the default browser is Safari, the hyperlinks bring to pages that just lines and lines of symbols. I need these links to work in both browsers. Any ideas?
version 10.6.8
-
What happened to page count, word count and the toolbar at the top?
Is there any way to edit the toolbar so that when I want to switch fonts I don't have to keep opening the toolbar on the side? (Is there anyway I can get the toolbar from the previous version back?)
Also, is there a way for the page count and word count to show up and stay there for future documents? I had the word count appear and tried to save that as a template but when trying to open up new documents I have to go back and make it so the word count shows up again.What Peter said.
Is there any way to edit the toolbar so that when I want to switch fonts I don't have to keep opening the toolbar on the side?
Yes. Menu > View > Customize Toolbar... drag/drop the Fonts icon adjacent to the Comments icon on the Toolbar. The Fonts icon now becomes a toggle to show/hide the Fonts toolbox, which you could also produce with a command+T.
(Is there anyway I can get the toolbar from the previous version back?
No.
Also, is there a way for the page count and word count to show up and stay there for future documents
No. Available via Menu > View > Show Word Count. This produces a floating box at the bottom of your document. When you roll over it with your mouse, you have a selection of words, characters, and paragraphs. The word count excludes spaces. -
My problem is cursor moves involuntary to a different paragraph or line; and additional overshadow words
You might want to consider starting a new discussion. Since this one is marked solved, less people are likely to look at it. You can link to this one.
-
HasMoreTokens detecting and counting empty line
Hi programmers!
how can i count empty line in a text file which has the data?
suppose the text file with data is as follows:
=====================
c 500
c 2100
// <== empty line
p 550
c 5950
c 3000
=====================
I want to display "Invalid record" when that empty line comes
I tried following to execute "IO.print("Invalid record") line
if(str.equals(" ")) / / also/ if (str.nextToken == false) /also / if (string.hasMoreTokens())
IO.print("Invalid record");
}If (line.equals(""))
or
if (line.trim().length() == 0) -
Count words in each sentece in a file
Hi all
i want to ask how can i count words in each sentece in a file??
ie if i have the follwoing sentece
i ate the cake.
today is Sundy.
i went to school 5 day a week.
to have the number as
4
3
8
any ideas??you could read the file line per line, put the line
in a string and use StringTokenizer to split it into
word and count them. Or you could read file char per
char, increasing the word counter everytime you find
a blank char, when the read char is a newline you
save the old counter and start a new word count for
the new line.That's an option, but a sentence is not ended by a newline. A sentence ends with a full stop/point.
Kaj -
Help !!
I am trying to count the number of words contained in a text area - Is it possible to do this ?
I am new to Java and I'm stuck because I only know how to write programs that use FileReader to count the number of words in a file.
Is it possible to count the number of words in a string directly - or will I have to save the string to file and then apply another program to count the number of words ?You inser this code in your source file (TextArea1 is the name of the TextArea, whose you want to count words)
String texte=TextArea1.getText();
String rt=String.valueOf((char)13) + String.valueOf((char)10);
StringTokenizer mots=new StringTokenizer(texte," ,.:;!?\t"+rt);
int nbremots=mots.countTokens();
and you place at the header of the file
import java.util.StringTokenizer;
nbremots is the number of words The delimitors between words are noticed in the second argument of the constructor of class StringTokenizer. I have choosen the main signes of punctuation like space, coma,stop... the String rt
symbolise return on Windows. If you work on Unix prefer this code
String texte=TextArea1.getText();
StringTokenizer mots=new StringTokenizer(texte," ,.:;!?\t\n");
int nbremots=mots.countTokens();
You can also with the class StringTokenizer read the words one by one with this type of boucle
while (mots.hasMoreTokens())
String mot=mots.nextToken();
mots.nextToken();
It is an useful class. See the API about this class StringTokenizer in the package java.util -
Hebrew typing problem in Word 2010 and 2013 in Windows 7 64bit
Hello,
When I am trying in Word (2010 and 2013 32bit installation) to edit a line (inserting a new word for instance in the middle of the line) or start a new line in RTL or LTR Hebrew paragraph I must first type the SPACE char and then to type any other letter. When
I try firs to type a regular letter it is not typed.
It happens only if the Word is installed on a Windows 7 professional 64bit version on my HP 8570p laptop. I formatted the laptop and installed the same OS but 32bit, installed the Office 2010 and the Word works perfect in any language. I formatted the Laptop
again, re-installed again the 64bit OS, installed the Office 2010 again and same symptom - cant type Hebrew letters if not starting with SPACE. If I try to edit the same paragraph with English letters it works OK. When I start a new line with English letters
it works OK. It seem that this symptom happens when the type direction is right-to-left (after ALT-right SHIFT stroke).
This symptom is only in Word. In PowerPoint, in Excel or any other Office application it works fine.
When using Word 365 (not installed localy even I have a local Word 2013 installation) the Hebrew typing is working fine.
I didn't change the default setting options of the Word not after installing the 32bit OS nor the 64bit OS.
I prefer to use the 64bit OS and not the 32bit OS so I do not consider moving to 32bit OS.Hello,
When I am trying in Word (2010 and 2013 32bit installation) to edit a line (inserting a new word for instance in the middle of the line) or start a new line in RTL or LTR Hebrew paragraph I must first type the SPACE char and then to type any other letter. When
I try firs to type a regular letter it is not typed.
It happens only if the Word is installed on a Windows 7 professional 64bit version on my HP 8570p laptop. I formatted the laptop and installed the same OS but 32bit, installed the Office 2010 and the Word works perfect in any language. I formatted the Laptop
again, re-installed again the 64bit OS, installed the Office 2010 again and same symptom - cant type Hebrew letters if not starting with SPACE. If I try to edit the same paragraph with English letters it works OK. When I start a new line with English letters
it works OK. It seem that this symptom happens when the type direction is right-to-left (after ALT-right SHIFT stroke).
This symptom is only in Word. In PowerPoint, in Excel or any other Office application it works fine.
When using Word 365 (not installed localy even I have a local Word 2013 installation) the Hebrew typing is working fine.
I didn't change the default setting options of the Word not after installing the 32bit OS nor the 64bit OS.
I prefer to use the 64bit OS and not the 32bit OS so I do not consider moving to 32bit OS. -
Please provide logic for schedule lines and material document Quantity.
Hi ABAPers,
Please help in the following context.
Is there any connecting or refrence field for which a particular schedule line item are considerd for the goods reciept of a particular material document.
Also provide the logic.
19 34
15
14 35
11
10
If 19 15 14 11 10 are schedule lines, and 34 35 are two recived quantities,
Then how can be the possible permutations and combinations logic to find out that, 34 = 19 + 15 and
35 = 141110.
Thanks in advance...Niles Raut wrote:
Hello Gurus,
>
> This is intracompany STO scenario with delivery. There is one STO for quantity say 1000 pc created in 2008. Delivery and PGI done for 1000 qty in 2008. Goods are received in receiving plant for qty 1000 in 2008. Now this delivery document is archieved and user has reversed the GR material document in 2010. Now this reversal material docuemnt has zero material qty becasue the delivery was archieved(which is the probable reson)
>
> When I want to cancel this reversal material document it gives error that "Qty and / or "delivery completed" ind. or final issue ind. are missing" which is logical since material document has zero quantity.
>
> Is there any sap notes or any other way to fix this?
>
> Please guide.
>
> Regards
> Nilesh
Where is actually the problem, if one only reversed 0 quantity?
Why do you think you need to reverse this reversal again?
why with year 2010?
Dont you do anual inventories? Such stock counts have corrected your stock anyway. if you start cancelling older movements then you create stock inconsistencies again. -
I have data that is in basic generic text file format that needs to be converted into Excel spreadsheet format. The data is much longer than 65536 lines, and in my code I haven't been able to figure out how to carry over the data into the next column. Currently the conversion is done manually and generates an Excel file that has a total of 30-40 full columns of data. Any suggestions would be greatly appreciated.
Thanks,
Darrick
Solved!
Go to Solution.No need to use nested For loops. No need for any loop anyway. You just have to use a reshape array function. The picture below shows how to proceed.
However, there may be an issue if your element number is not a multiple of the number of columns : zero value elements will be added at the end of the last column in the generated 2D array. Now the issue depends on the way you intend store the data in the Excel spreadsheet : you could convert the data as strings, replace the last zero values with empty strings, and write the whole 2D array to a file (with the .xls extension ) using the write to spreadsheet function. Only one (minimal) problem : define the number of decimal digits to be used;
or you could write the numeric array directly to a true Excel spreadsheet, using either the NI report generation tools or ActiveX commands, then replace the last elements with empty strings.
We need more input from you to decide how to solve these last questions.
Message Edité par chilly charly le 01-13-2009 09:29 PM
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Attachments:
Example_VI.png 10 KB -
Counting words in a single cell in Numbers'09
Hi there,
I'm relatively new to Mac world, but I do have years of computer experience from a PC and have also had to do with Macs at the age of first eMacs . I have finally decided to switch to the brighter side of life (hopefully ;)).
But here is my question: I need to count words in a cell in Numbers'09.
Is there a specific function combination for achieving this? My idea was: strip excessive spaces, count the occurencies of all space character in a cell, add 1 and voila! Problem is I can not achieve it using formulas in Numbers'09. I have found some help for Excell but the formulas are a little different. And well, I would like to leave the past behind and stick to a Apple programs - if I can. I don't like the idea to install Excell on a Windows Bootcamp partion only for this purpose.
Any help would be greatly appreciated. Thanks.
AleksanderBadunit wrote:
Yvan once had a list of all the different localizations. He may still have it.
I'm late but, I was very busy
The table with every localized functions names is (and will remain) available on my iDisk :
<http://public.me.com/koenigyvan>
Download :
For_iWork:iWork '09:functionsNames.numbers.zip
An easy soluce for foreign users (like me) is to duplicate Numbers.app and remove its languages resources minus English.
Running it you will have it running in English (minus the decimal and the parameters separators, minus also date time formats and default currency).
It would be easy to enter the formulas given in this forum.
Once saved, we may open the doc in the 'standard' Numbers and the formulas will be automatically localized.
Yvan KOENIG (VALLAURIS, France) mardi 2 mars 2010 18:30:45 -
Pls Help about counting the lines of the file in java
private int GrepPBArequestLog(String STRexpression) throws IOException
int totalnum = 0;
try {
String[] cmd = {"grep", "-ic", STRexpression, src};
System.out.println("grep, cmd " STRexpression" "+src);
Process grepProc = Runtime.getRuntime().exec(cmd);
String line = "";
BufferedReader br = new BufferedReader(new InputStreamReader(grepProc.getInputStream()));
line = br.readLine();
System.out.println("read: "+line);
while (line != null)
System.out.println("Line: "+line);
line = line.substring(line.indexOf(":") + 1, line.length());
System.out.println("Substring: "+line);
try
int temp = Integer.parseInt(line);
totalnum = totalnum + temp;
catch(NumberFormatException e)
System.out.println("String: "+line);
System.out.println("NumberFormatException Occured"+e.getMessage());
}//end while
the output is:
service No: 209
Wapdate: 07/Jul/2003
Went inside: GrepPBArequestLog
grep cmd .*07/Jul/2003.*GET.*209.* /var/log/httpd/access_log*
Line:
read: null
totalnum: 0
wap 07/Jul/2003:
wap 209:
total hits 209: 0
+++++++++++++++++++++++++++++++++
the read: should not be null because there is a number of lines and
totalnum shouldn't be 0.You don't want to simply:
import java.io.*;
public class CountEm {
private static BufferedReader br;
private static int count;
private static String fileName, record;
public static void main(String[] argv) {
switch(argv.length) {
case 1: { fileName = argv[0]; break; }
default: { System.out.println("Usage: java CountEm [filename]"); System.exit(-1); }
try { countEm(); }
catch(IOException ioe) { System.out.println("ERROR doing countEm()\n"+ioe); }
finally { System.out.println("Count: "+count); }
public static void countEm() throws IOException {
br = new BufferedReader(new FileReader(fileName));
while ( ( record = br.readLine() ) != null ) { count++; }
}~Bill
Maybe you are looking for
-
How do I get the music from itunes on my computer on my ipod touch
I have music on my playlist in Itunes on my computer but it isn't transferring to my Ipod Touch. How do I do this?
-
Kernel Panic... Log Attached
I have been experiencing a LOT of OS X crashes lately. I am attaching the Panic Log because I don't know how to read it. Two recent changes to my system: on 2/24/09, I added an additional 1.5 Tb internal drive. I had also installed some Ram, but it w
-
I would like to know the best way to creat WMV files with a Mac. I need to be able to put my video presentations on my HP Ipaq that only excepts WMV files for video.
-
Hi, Now I have one VS project which referred to dotnet 4.5 dlls, but my project must compile with target to dotnet 3.5. How could I do that? Is there any workaround? Can MEF implement to fix this? Thanks.
-
How to automate tasks in indesign ?