Skip to content

Instantly share code, notes, and snippets.

@spara
Created February 6, 2012 16:44
Show Gist options
  • Select an option

  • Save spara/1753211 to your computer and use it in GitHub Desktop.

Select an option

Save spara/1753211 to your computer and use it in GitHub Desktop.
Using sed
#
# replace the "." values with nulls using sed and write to
# another file
#
sed 's/\"\.\"//g' campus_dropout.csv > campus_dropout_clean.csv
#
# check the output of the new file
#
$ head -n 2 campus_dropout_clean.csv
"CAMP_SPEN","CAMP_SPER","CAMP_SPED","CAMP_OVRN","CAMP_OVRR","CAMP_OVRD","CAMP_MIGN","CAMP_MIGR","CAMP_MIGD","CAMP_LEPN","CAMP_LEPR","CAMP_LEPD","CAMP_IMMN","CAMP_IMMR","CAMP_IMMD","CAMP_GFTN","CAMP_GFTR","CAMP_GFTD","CAMP_ECNN","CAMP_ECNR","CAMP_ECND","CAMP_CTEN","CAMP_CTER","CAMP_CTED","CAMP_TTLN","CAMP_TTLR","CAMP_TTLD","CAMP_BEN","CAMP_BER","CAMP_BED","CAMP_ATRN","CAMP_ATRR","CAMP_ATRD","CAMP_MUN","CAMP_MUR","CAMP_MUD","CAMP_PIN","CAMP_PIR","CAMP_PID","CAMP_WHN","CAMP_WHR","CAMP_WHD","CAMP_NAN","CAMP_NAR","CAMP_NAD","CAMP_HSN","CAMP_HSR","CAMP_HSD","CAMP_ASN","CAMP_ASR","CAMP_ASD","CAMP_AAN","CAMP_AAR","CAMP_AAD","CAMP_FEMN","CAMP_FEMR","CAMP_FEMD","CAMP_MALN","CAMP_MALR","CAMP_MALD","CAMP_ALLN","CAMP_ALLR","CAMP_ALLD","DISTRICT","Gradespan","campus","cntyname","regnname","campname","distname","COUNTY","REGION"
"0","0.0","28","-","3.7","<100",,,,,,,,,,"0","0.0","24","-","1.5","<100","0","0.0","45","-","1.4","<300",,,,"-","4.4","<100","0","0.0","10",,,,"-","1.8","<200",,,,"0","0.0","9","0","0.0","1","0","0.0","29","-","2.3","<100","-","0.8","<200","-","1.4","<300","001902","712","001902001","Anderson County","Kilgore","Cayuga H S","Cayuga ISD","001","07"
#
# remove the column header
#
$ cp campus_dropout_clean.csv tmp
$ sed '1d' tmp > campus_dropout_clean.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment