Timeline for Replace only certain double quotes in data file
Current License: CC BY-SA 3.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Apr 13, 2018 at 6:43 | history | suggested | Bharat | CC BY-SA 3.0 |
Updated sample input and output for better clarity
|
| Apr 13, 2018 at 6:08 | review | Suggested edits | |||
| S Apr 13, 2018 at 6:43 | |||||
| Apr 5, 2018 at 16:00 | answer | added | Ora Clesismo | timeline score: 0 | |
| Apr 4, 2018 at 17:24 | comment | added | Nasir Riley | I apologize if you took it as me stating that you're doing it wrong but that's not how I meant it. I was simply trying to help. If the answers given by others helped you with this issue then that's what's important. I'm only suggesting a RDBMS such as Mysql so that you don't have to worry about manually setting delimiters or escaping special characters as much. Perhaps you can't just migrate your production DB to a different system but I suggest trying it out as it is designed to make things run more smoothly by avoiding issues such as this. | |
| Apr 4, 2018 at 17:03 | comment | added | Ora Clesismo | In your defense, I may have used the term "delimiter" loosely... In my defense however, the example given in the original question was pretty clear. Before and After examples are the best! :) | |
| Apr 4, 2018 at 17:00 | comment | added | Ora Clesismo | The question at hand was how to escape a double quote within the contents of a string (example given in the original question), in our case we're after adding an additional double quote to escape it. I appreciate your input, I really do, but your approach was "you're doing it wrong" which to be fair gave it some thought (you could be right) but unfortunately the facts didn't change - we need to escape a double quote within a file. It's not about disclosing why we're doing what we're doing - granted there's room in this forum for "why are you doing it that way?" etc. It's not the case here | |
| Apr 4, 2018 at 16:28 | comment | added | Nasir Riley | Just to help you out in the future, I suggest looking into Mysql instead of using a flat file database. It has its own delimiters built in so that don't have to worry about escaping characters anywhere near as much. That would help you to avoid this situation. | |
| Apr 4, 2018 at 16:23 | comment | added | Nasir Riley |
I don't mean to be condescending but your use of the term delimiter is rather off. A delimiter is used to separate columns. What you are doing with the quotes is escaping a special character and not separating columns. In your case, there's no reason to surround the contents of every column with quotes unless every column has a pipe in it. It may be better to use a tab as a delimiter instead of pipes but either way, the quotes in every column aren't needed and are just adding complications.
|
|
| Apr 4, 2018 at 15:49 | answer | added | ctac_ | timeline score: 0 | |
| Apr 4, 2018 at 15:28 | comment | added | Ora Clesismo | The pipe | can be found within the data as well, that would throw off the import... so the double quotes " are necessary to escape that situation. It's very common for ETL files to have a column delimiter and a text delimiter. The problem in our case was that the text delimiter could be found within the data as well... so that needs to be escaped as well, for our purpose, escaping it with a second double quote takes care of the problem. | |
| Apr 4, 2018 at 11:52 | comment | added | Nasir Riley | The pipe is already a delimiter for both of them. By its very definition, it separates all of the text into different columns. I can understand why you need double quotes to specify height, width, and length but it really isn't necessary for the rest. Even when using double quotes to specify height, width, and length, the pipe acts as a delimiter for each field no matter what value or characters are contained inside which makes the other double quotes unnecessary and redundant. It's only a suggestion on my part as it would make your database a lot easier to manage. | |
| Apr 4, 2018 at 9:36 | history | edited | Jeff Schaller♦ | CC BY-SA 3.0 |
added 8 characters in body; edited tags
|
| Apr 4, 2018 at 7:49 | answer | added | Bharat | timeline score: 0 | |
| Apr 4, 2018 at 6:49 | answer | added | ErikF | timeline score: 0 | |
| Apr 4, 2018 at 3:47 | comment | added | Ora Clesismo | We’re after a way to escape the text delimiter which in our this case is “ (our only choice for text delimiter) that is found in the data ie 5’6” | |
| Apr 4, 2018 at 3:45 | comment | added | Ora Clesismo | Hence we have to use column and text delimiters. I apolologize if my statement was t clear when I said escaping the data... I meant to say escaping the data which includes “ within the data. | |
| Apr 4, 2018 at 3:43 | comment | added | Ora Clesismo | The pipe can be found within data as well ie “2433” | “Concatenate the fields with | in your summary” | “5’6” tall” | |
| Apr 4, 2018 at 2:48 | comment | added | Nasir Riley |
What do you mean by escaping the data? Why not just use the pipe by itself as a delimiter as that would separate the text into each column just as a space, tab, or comma would? You are complicating things where it isn't necessary by using double quotes when you already have the pipe as a delimiter. If it's just text within a file then you don't need to escape it unless you are using a command such as sed to alter the file and need to work with the text on the command line. If that's the case, you can just escape it with backslashes or single quotes.
|
|
| Apr 4, 2018 at 1:58 | review | First posts | |||
| Apr 4, 2018 at 2:15 | |||||
| Apr 4, 2018 at 1:54 | history | asked | Ora Clesismo | CC BY-SA 3.0 |