I need to use Perl in a Windows environment at work, and I need to find out the number of lines that a large csv file contains (about 1.4Gb). Any idea how to do this with minimal resources?
thanks
PS This should be done in a Perl script, and we are not allowed to install any new modules on the system.
? , , . , , Perl FAQ. CSV, Text:: xSV.
, perl.
; wc.exe
Windows, unix.
http://unxutils.sourceforge.net/
:
PS D:\> wc test.pl 12 26 271 test.pl PS D:\>
12 == , 26 == , 271 == .
perl;
D:\>perl -lne "END{print $.;}" < test.pl 12
perl -lne "END { print $. }" myfile.csv
, , .
.
perl -ne 'BEGIN{$re=qr/^[^"]*(?:"[^"]*"[^"]*)*?"[^"]*$/;}END{print"Count: $t\n";}$t++ unless /$re/../$re/'
wc
Text::CSV
</" > EDIT:. , :
perl -ne "BEGIN{$re=qr/^[^\"]*(?:\"[^\"]*\"[^\"]*)*?\"[^\"]*$/;}END{print qq/Count: $t\n/;};$t++ unless $pq and $pq = /$re/../$re/;"
, Broken OS && exec , , !! , , .
&&
Upvote for edg's answer, another option is to install cygwin to get wc and a bunch of other useful utilities on Windows.
I was an idiot, an easy way to do this in a script:
open $extract, "<${extractFileName}" or die ("Cannot read row count of $extractFileName"); $rowCount=0; while (<$extract>) { $rowCount=$rowCount+1; } close($extract);
Source: https://habr.com/ru/post/1706469/More articles:Dynamically display links using ASP.NET LoginView - asp.netОграничение отношения "один ко многим" - sqlSplitting a DLL utility into smaller components in C ++ - c ++Should a web browser delete all `session 'cookies (expiry = 0) upon exit? - browserStoring jquery code in external file and directory structure? - javascriptWebPart Security - sharepointUnable to insert string into MySQL text table - syntaxDatabase transfers: manage using build script or automatically when application starts? - build-processCompare the text of the two methods - diffASP.NET - conditionally link CSS file - cssAll Articles