shell_scripting
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
shell_scripting [2023-09-21 04:46 pm] – [Merging CSV files in the current directory] hcho | shell_scripting [2023-09-21 05:15 pm] (current) – hcho | ||
---|---|---|---|
Line 35: | Line 35: | ||
done > merged.csv # forward any outputs from the above for loop | done > merged.csv # forward any outputs from the above for loop | ||
# to merged.csv | # to merged.csv | ||
+ | </ | ||
+ | |||
+ | ===== Finding the order of a column in a CSV file ===== | ||
+ | |||
+ | <code bash> | ||
+ | head -1 merged.csv | | ||
+ | sed ' | ||
+ | awk '{ | ||
+ | for(i=1; i<=NF; i++) | ||
+ | if($i == " | ||
+ | print i | ||
+ | }' | ||
+ | </ | ||
+ | |||
+ | ===== Counting non-null records in a column in a CSV file ===== | ||
+ | |||
+ | <code bash> | ||
+ | tail -n +2 merged.csv | | ||
+ | sed ' | ||
+ | awk '{ | ||
+ | if($57 != "" | ||
+ | count++ | ||
+ | } | ||
+ | END{ | ||
+ | print count | ||
+ | }' | ||
</ | </ |
shell_scripting.1695336368.txt.gz · Last modified: 2023-09-21 04:46 pm by hcho