Tag Info

New answers tagged

0

The problem with CSV is that there is no standard. If you need to deal with CSV-formatted data often, you might want to look into a more robust method rather than just using "," as your field separator. In this case, Perl's Text::CSV CPAN modules are exceptionally well-suited to the job: $ perl -mText::CSV_XS -WlanE ' BEGIN {our $csv = ...


1

It gets a bit long as you seem to have blank lines in the input. The following might work for you: awk -F'[, ]' '{if (NF!=0 && $1=="") {$1=prev} prev=$1}1' OFS=, inputfile The idea is to split fields on , and whitespace (the latter in order to handle the first line of input). Check if the first field is blank and the number of fields is not zero ...



Top 50 recent answers are included