We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Count number of lines in csv files in a folder

Hi I want to count number of lines in csv files in a folder and display it,

I have the code to count number of lines,but the problem is i want to loop all the files in that folder and display it ,

For eg: in Month January folder ,I have files with file names week1,week2,week3,week4

I want to display the the number of lines in january folder ie. number of lines in week1+number of lines in week2+number of lines in week3+number of lines in week4.

I it possible.

The code to count number of lines in a single file is

<?php

$linecount = count(file("Desktop/countries.csv"));
echo $linecount;
?>


Thanks

2
Contributors
1
Reply
2 Weeks
Discussion Span
1 Year Ago
Last Updated
2
Views
rahulroshan
Light Poster
28 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

for i in `ls`
do
LC='wc -l ${i} | cut -d\ -f1`
let COUNT=${COUNT}+${LC}
done
echo ${COUNT}

ennoil
Newbie Poster
17 posts since May 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.5083 seconds using 2.63MB