I am processing some CSV data from a client and one of the headers is 'booktitle'. The values of 'booktitle' are text qualifed with double quote and there are quotes in some of the titles, such as;
"How to draw the "Marvel" way"
I asked the client to escape the quotes in quotes with double quotes, and they sent me back this
'"How to draw the """Marvel""" way "'
So single, double, then triple quote. My question is will this work? I have not seen it done this way before for escaping text qualifiers.
Which way are you using to save the info?
If you are saving it directly from SQL, double quotes are not a problem as SQL use single quotes.
If you are using a program, use SqlParameters. It will wrap you everything
Oracle Setup:
CREATE TABLE BOOKS(
ID INT,
TITLE VARCHAR2(4000)
);
CSV:
ID,TITLE
1,"How to draw the ""Marvel"" Way"
2,"Test ""Someone's Data"""
(One double quote at start and end, two double quotes to escape a double quote in the middle of the string and single quotes don't need to be escaped.)
Import via Oracle SQL Developer
In the connections pane, right click the table name and select "Import Data..."
Browse and select the CSV file then the default values will be sufficient so click "Next >".
Set the Import Method to "Insert" and deselect "Send Create Script to SQL Worksheet" then click "Next >" three times.
Click "Finish" and the data will be imported.
Related
I have a csv source file with comma (,) delimiter and values are enclosed with double quotes (") and using Text file Input to read the data in PDI 8.3. I am using , in Separator and " in Enclosure options in Content tab.
However, there is a field that contains quotes within the double quotes in the values itself, see the example below:
"abc","cde",
"abc" - 1st col
"cde" - 2nd col
"ef"A"gh" - 3rd col
"ijk" - 4th col and so on..
And issue in the 3rd col, in output it's reading "ef" as 3rd col and remaining values is passing to the next subsequent col. Hope I am able to clarify the issue here, only Expecting to escape the " within the values.
I have tried " in the Escape option but it's not working. Can someone please suggest how to handle this.
Thanks!
You can just leave the Enclosure attribute empty. That way the string will only be divided into columns by the Delimiter.
See CSV File Input Doc and Text File Input Doc
I'm new to Pentaho 8.3 CE (Spoon) and am trying add an extra column to a CSV file by concatenating 3 other text fields together. I'm using 2 options - Calculator and the inbuilt 'Concat fields' transformations.
The issue I'm facing is that some rows are enclosed by " " while others aren't... e.g.
Field A = "One thing, another thing"
Field B = Yet another thing
Field C = Final thing
Ideally, I want,
New field = "One thing, another thing Yet another thing Final thing",
I find I can't get the final " to enclose each line, so it looks like "One thing, another... Final thing
How do I get Pentaho to add that final " on? I've set to force the enclosure on.
enter image description here
First strip the double quotes with a String operations step or a Replace in String step (the latter allows regexp search and replace).
The use a Concat strings step to join them all together comma separated.
Finally, either prepend & append double quotes, or when writing out with e.g. a text file output, add the enclosure character.
I'm writing a function to scrape data from a website using xpath strings like this:
//*[#id="mw-content-text"]/div/table[1]/tbody/tr[14]
As Obvious, when I assign this string to a variable I get a syntax error due to the presence of the quotation marks.
I already know some ways to manually correct the text and avoid errors.
My question is if there's a way to put the text into a variable "as it is".
Thanks in advance.
There is no problem at all assigning this string to a variable "as is". E.g. write the string(s) into a table and read it from a recordset.
But if you want to hard-code the string in your VBA source code, you need to escape the quotes by duplicating them.
Const xPath As String = "//*[#id=""mw-content-text""]/div/table[1]/tbody/tr[14]"
Is there a keyboard shortcut to toggle between single quotes and double quotes in a Ruby code? Or a key I can set up to accept the Inspection Hint?
Thanks, M.
To accept any inspection hint in RubyMine, press Alt+Enter and then use the arrow keys and Enter to select the quickfix to apply.
Current as of RubyMine 2016.2, there is an easier way to convert all quotes via the keyboard:
select part of string whose quotation type you want to change
Alt + Enter to accept inspection hint
Arrow right
"Fix all 'Double quoted string' problems in file"
Suppose you have a double quoted string as "some_string" then you need to select all "some_string" including both the quotes and press quote key to get 'some_string' i.e single quoted string. To get the double quotes 'some_string' => "some_string" follow the same process and press shift+quote key. Hope your problem is solved #Martin.
I am using an SQL database in an android app and have encountered a problem with apostrophes.
My database is a quotes database which I have in MS Excel 2007, then saved in .csv format. I then imported this into the sql table I have for the app. However the quotes with an apostrophe are not displaying correctly in the database (and therefore the app). Each apostrophe is replaced with a character that is invisible. I know it is there because of the character count and the fact that in the word "aren't" for example which looks like "arent" it take 3 clicks of the right arrow to get from the left side of the n to the right side of the t. If I manually add an apostrophe to the sql table it converts back to this invisible character when the database is saved. In the android app this invisible character shows up as a hollow rectangle.
I am sure the issue does not lie in my app's displaying of the quote because I have passed in a String to the same code and it displays apostrophes perfectly fine.
Is there a way to fix this issue, possibly by changing the character set or something like that? or does SQL not support apostrophes?
Since a single quote and apostrophe are the same character you have to do something in sql to tell the database when to treat it as part of a string or when to use it to surround a string. In every RDBMS of which I am aware, if you want the character to be part of a string, you "quote the quote", ie you change ' to '' when talking to your database.
That seems to be only part of your problem. The other part is that your android app displays this character as a rectangle instead or an apostrophe. That's got nothing to do with sql. That is a function of the android application.
I found an alternative solution to the problem.
At runtime of the app I'm replacing the invisible character with an apostrophe and the final string is then how the quote should look.
String quote = (get the quote from the SQL table)
char[] tempQuoteCharArr = new char[quote.length()];
tempQuoteCharArr = quote.toCharArray();
for(int i = 0; i < quote.length(); i++){
if(tempQuoteCharArr[i] == ''){
tempQuoteCharArr[i] = '\'';
}
}
quote = String.valueOf(tempQuoteCharArr);
The invisible character is between the single quotes in the if statement.