LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices



Reply
 
Search this Thread
Old 04-16-2014, 09:13 AM   #1
sayhello_to_the_world
Member
 
Registered: May 2013
Posts: 170

Rep: Reputation: Disabled
counting the rows in calc


how to counting the rows

see the example..

shop name
supermarket Netto
supermarket Penny
supermarket Rewe
supermarket netto
supermarket Lidl
supermarket Netto

is there an easy way to do this
 
Old 04-16-2014, 12:02 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,102

Rep: Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719
Quote:
Originally Posted by sayhello_to_the_world View Post
how to counting the rows see the example..

shop name
supermarket Netto
supermarket Penny
supermarket Rewe
supermarket netto
supermarket Lidl
supermarket Netto

is there an easy way to do this
There are several ways to do this, but you don't tell us what you're wanting to use. Perl? Bash? Ruby? What is your delimiter between the 'rows'? What have you done/tried on your own?? What are you trying to accomplish?

You can easily use sed and awk to get the maximum number of columns, by counting the delimiters. Running it through sort and head would return just the highest number.
Code:
sed 's/[^<some delimiter>]//g' <file name> | awk '{ print length }' | sort -r | head -n 1
Please try to show some effort of your own first.
 
Old 04-21-2014, 09:34 AM   #3
AnanthaP
Member
 
Registered: Jul 2004
Location: Chennai, India
Distribution: UBUNTU 5.10 since Jul-18,2006 on Intel 820 DC
Posts: 659

Rep: Reputation: 160Reputation: 160
He said "calc" right. I think that means OO/Libre Calc.

Use COUNTA() function. Just COUNT() counts only numerics. COUNTA() counts text also and ignores empty cells. COUNTBLANK() returns the number of empty cells.

OK
 
Old 04-21-2014, 11:32 AM   #4
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,102

Rep: Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719Reputation: 2719
Quote:
Originally Posted by AnanthaP View Post
He said "calc" right. I think that means OO/Libre Calc.
Use COUNTA() function. Just COUNT() counts only numerics. COUNTA() counts text also and ignores empty cells. COUNTBLANK() returns the number of empty cells.
Or it could mean any program with 'calc' in the name...since the OP didn't say, and never followed up, it's hard to guess.

Either way, the count() solution you provided is a good one...but is also another that the OP could have easily looked up.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] awk certain rows sryzdn Linux - Newbie 1 10-06-2013 01:37 AM
awk comparing 2 rows and counting secret Linux - Newbie 7 03-12-2013 09:36 PM
Colorizing rows/columns in Open Office Calc hedron Linux - Software 3 06-09-2010 11:51 PM
Compare two fields on consecutive rows and print the two rows aditi_borkar Linux - Newbie 3 04-09-2009 06:49 AM
rows and columns digitalgravy Linux - General 2 03-16-2004 07:47 PM


All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration