Quantcast
Channel: Count the maximum character length for all the data fields in a simplified csv file and output to txt - Unix & Linux Stack Exchange
Browsing latest articles
Browse All 5 View Live

Answer by G-Man for Count the maximum character length for all the data...

If I understand your question correctly, this will do what you want: awk -F, 'NR!=1 { if (max_NF < NF) max_NF = NF; for (i=1; i<=NF; i++) if (max[i] < length($i)) max[i] = length($i) } END {...

View Article


Answer by Raza for Count the maximum character length for all the data fields...

I don't see your link for the sample file but you can do this by using awk command. if can specify what ever delimiter you may have and exactly what field you need to count. awk '{ FS = "," } ; {...

View Article


Count the maximum character length for all the data fields in a simplified...

Given a simplified CSV (max one line per row) with many data fields (>50), how can I count the maximum character length for each data field and then export all the counts to a txt file? BTW, I want...

View Article

Answer by Kusalananda for Count the maximum character length for all the data...

Using Miller (mlr) to calculate the max length of each field's values. The input is read as CSV, and the output is produced as an "xtab" file (one key+value pair on each):$ mlr --c2x stats1 -a maxlen...

View Article

Answer by jubilatious1 for Count the maximum character length for all the...

Using Raku (formerly known as Perl_6)~$ raku -ne 'BEGIN my @a; unless ++$ == 1 { @a.push: $_.split(",").map: *.chars; }; END say( ++$ ~ " | " ~ $_ ) for ([Z] @a).map: *.max;' fileOR:~$ raku -ne 'BEGIN...

View Article

Browsing latest articles
Browse All 5 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>