Skip to main content
Updated sample input and output for better clarity
Source Link

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

“164829”"164829" | “collection"collection 1”1" | “wood"wood plank 2”2" x 4”4" long”long" | “23"23.5”5" 
"2017"|"S"|"221318"|"WE"|"20170118"|"Someones name"|"20170215"|"1785"|"009"|"20170215"|"182339"|"99536"|"00090"|"LOCAL00"|"930N"|"2017"|"6100"|"0000880"|1.000|0.000|"EA"|" "|" "|" "|" "|"005"|"00000000"|" "|" "|"1785"|"50228"|"R"|"2017"|"NMT CAUTION| 5" X 3" NAT ON BLK"|" "|" "|"USD"|"7444"|" "|"000"|"COIN"|"04"|35.00|"00"

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

“164829”"164829" | “collection"collection 1”1" | “wood"wood plank 2””2"" x 4””4"" long”long" | “23"23.5”5"
"2017"|"S"|"221318"|"WE"|"20170118"|"Someones name"|"20170215"|"1785"|"009"|"20170215"|"182339"|"99536"|"00090"|"LOCAL00"|"930N"|"2017"|"6100"|"0000880"|1.000|0.000|"EA"|" "|" "|" "|" "|"005"|"00000000"|" "|" "|"1785"|"50228"|"R"|"2017"|"NMT CAUTION| 5"" X 3"" NAT ON BLK"|" "|" "|"USD"|"7444"|" "|"000"|"COIN"|"04"|35.00|"00"

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

“164829” | “collection 1” | “wood plank 2” x 4” long” | “23.5” 

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

“164829” | “collection 1” | “wood plank 2”” x 4”” long” | “23.5” 

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

"164829" | "collection 1" | "wood plank 2" x 4" long" | "23.5" 
"2017"|"S"|"221318"|"WE"|"20170118"|"Someones name"|"20170215"|"1785"|"009"|"20170215"|"182339"|"99536"|"00090"|"LOCAL00"|"930N"|"2017"|"6100"|"0000880"|1.000|0.000|"EA"|" "|" "|" "|" "|"005"|"00000000"|" "|" "|"1785"|"50228"|"R"|"2017"|"NMT CAUTION| 5" X 3" NAT ON BLK"|" "|" "|"USD"|"7444"|" "|"000"|"COIN"|"04"|35.00|"00"

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

"164829" | "collection 1" | "wood plank 2"" x 4"" long" | "23.5"
"2017"|"S"|"221318"|"WE"|"20170118"|"Someones name"|"20170215"|"1785"|"009"|"20170215"|"182339"|"99536"|"00090"|"LOCAL00"|"930N"|"2017"|"6100"|"0000880"|1.000|0.000|"EA"|" "|" "|" "|" "|"005"|"00000000"|" "|" "|"1785"|"50228"|"R"|"2017"|"NMT CAUTION| 5"" X 3"" NAT ON BLK"|" "|" "|"USD"|"7444"|" "|"000"|"COIN"|"04"|35.00|"00"
added 8 characters in body; edited tags
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 264

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

“164829” | “collection 1” | “wood plank 2” x 4” long” | “23.5”

“164829” | “collection 1” | “wood plank 2” x 4” long” | “23.5” 

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

“164829” | “collection 1” | “wood plank 2”” x 4”” long” | “23.5”

“164829” | “collection 1” | “wood plank 2”” x 4”” long” | “23.5” 

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

“164829” | “collection 1” | “wood plank 2” x 4” long” | “23.5”

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

“164829” | “collection 1” | “wood plank 2”” x 4”” long” | “23.5”

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

“164829” | “collection 1” | “wood plank 2” x 4” long” | “23.5” 

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

“164829” | “collection 1” | “wood plank 2”” x 4”” long” | “23.5” 
Source Link

Replace only certain double quotes in data file

We extract data from a database to a flat file, we use a pipe for column delimiter and double quotes for text delimiter.

Data file looks Something like this:

“164829” | “collection 1” | “wood plank 2” x 4” long” | “23.5”

What command/script could find every case where the data (not including the text delimiter) can be escaped with a second double quote?

The end result should look like this:

“164829” | “collection 1” | “wood plank 2”” x 4”” long” | “23.5”