Skip to main content

I just had the same problem, but the cut/paste answer didn't quite work for me as I wanted a blank field, so this worked for me:

  1. Find out how many lines you have in the file you are inserting:

     wc -l file.csv
    
  2. (so so let's say (1)1. gave you 30)...use then use a bash loop to insert a null field between fields 3 & 4:

     paste -d, <(cut -d, -f-3 file.csv) <(for i in `seq 1 30`; do echo; done) <(cut -d, -f4- file.csv) > fileNew.csv
    

I just had the same problem, but the cut/paste answer didn't quite work for me as I wanted a blank field, so this worked for me:

  1. Find out how many lines you have in the file you are inserting:

     wc -l file.csv
    
  2. (so say (1) gave you 30)...use a bash loop to insert a null field between fields 3 & 4:

     paste -d, <(cut -d, -f-3 file.csv) <(for i in `seq 1 30`; do echo; done) <(cut -d, -f4- file.csv) > fileNew.csv
    

I just had the same problem, but the cut/paste answer didn't quite work for me as I wanted a blank field, so this worked for me:

  1. Find out how many lines you have in the file you are inserting:

    wc -l file.csv
    
  2. so let's say 1. gave you 30 then use a bash loop to insert a null field between fields 3 & 4:

    paste -d, <(cut -d, -f-3 file.csv) <(for i in `seq 1 30`; do echo; done) <(cut -d, -f4- file.csv) > fileNew.csv
    
Source Link

I just had the same problem, but the cut/paste answer didn't quite work for me as I wanted a blank field, so this worked for me:

  1. Find out how many lines you have in the file you are inserting:

     wc -l file.csv
    
  2. (so say (1) gave you 30)...use a bash loop to insert a null field between fields 3 & 4:

     paste -d, <(cut -d, -f-3 file.csv) <(for i in `seq 1 30`; do echo; done) <(cut -d, -f4- file.csv) > fileNew.csv