This question already has an answer here:
- Remove an array column from a CSV file 3 answers
A0021,,Outside state ambulance serv,I,,0,0,, A4217,,"Sterile water/saline, 500 ml",X,, A4672,,"Drainage ext line, dialysis",X,,
Example output after first sed command
sed -i 's/("[^,])[,]([^"]")/\1\2/g' file.csv :
A0021,,Outside state ambulance serv,I,,0,0,, A4217,,"Sterile water/saline, 500 ml",X,, A4672,,"Drainage ext line dialysis",X,,
Desired output after the last command:
A0021,,,I,,0,0,, A4217,,,X,, A4672,,,X,,
The third column has been giving me issues in a project and the easiest solution is to simply delete it, as it is not necessary. The commas should remain, it should just have empty contents.
I was thinking that I would need to develop a
sed command to remove the commas contained within quotes before the command to delete the third column, as I would imagine that the easiest way to do this would be to count the commas and then delete everything between the 2nd and 3rd comma.
this is the sed command I am using the delete the commas inside of the quotes before I proceed with clearing the 3rd column's contents