Created
April 11, 2018 03:51
-
-
Save vapniks/499b908ace3345ed0f24fe1ca0e79da9 to your computer and use it in GitHub Desktop.
A simple awk script to check a .csv file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN {FS=","} | |
$1 !~ /^[0-9]+$/ {print "Line "NR": Field 1 invalid"} | |
$2 !~ /^"?[a-zA-Z][^,]+"?$/ {print "Line "NR": Field 2 invalid"} | |
$3 !~ /^[0-9.]+$/ {print "Line "NR": Field 3 invalid"} | |
$4 !~ /[0-9]+/ {print "Line "NR": Field 4 invalid"} | |
$5 !~ /[0-9](\.[0-9])? - [0-9](\.[0-9])?/ {print "Line "NR": Field 5 invalid"} | |
/^$/ { print "Line "NR" is empty" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment