Datatables search and filter problem with quotation marks - datatables

I have problem with Datatables search by column or in general when variable has value like this
var = 'Company "name" ';
When i searchin like name it works correctly, but when i paste exact value Company "name" there is no results i guess the problem is in quotation marks maybe someone found solution? because those trings with quotation marks is in my DB.

My problem solution was use PHP. What I did changed array object property value using str_replace before pushing data to Datatables. So in db those values with quotation marks but when data goes to datatable those values without quotation marks

Related

Put not editable text with quotation marks in a string variable

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]"

Create New Field QGIS Depending on Another Field Using Case

I'm looking to create a new field in QGIS that is relying on the data contained in another field.
I'm using the field calculator and the case function, but it seems to be trying to pull my conditional string as a field for some reason!
It looks like this - I'm trying to create a new field depending on the existing LEASE field, where its values are Interested, or Toronto.
CASE
when LEASE Like "Interested" or "Toronto" then "Participating"
Else "Non-Participating"
End
The error I get is
Column Interested is not found
Any ideas?
Double quotes are for delimited identifiers. Use single quotes for string literals:
CASE
when LEASE IN ('Interested', 'Toronto') then 'Participating'
Else 'Non-Participating'
End
That OR part has been replaced with an IN, to save some typing. You could also do when LEASE = 'Interested' OR LEASE = 'Toronto' then, but IN is more convenient.

In Excel VBA, how do I refer to a named column that contains a single quote

I am investigating a bug in an Excel spreadsheet where the following formula is inserted into every cell in a column.
=AGGREGATE( 3, 5, InputData[#[Foo]:[Bar]]) > 0
The VBA is as follows:
Let AddColumn.DataBodyRange.formula = "=AGGREGATE( 3, 5, [#[Foo]:[Bar]]) > 0"
this will evaluate to FALSE if all of the cells on the current row between columns Foo and Bar are empty, otherwise it evaluates to TRUE
The problem I'm seeing is that the names Foo and Bar are variable and not under my control and the formula fails with Run-time error 1004 if a name contains a single quote:
Let AddColumn.DataBodyRange.formula = "=AGGREGATE( 3, 5, [#[Foo's name]:[Bar]]) > 0"
Is there a way I can escape the name in such a way that single quotes won't create the run-time error? Adding double quotes around the name gives me the same error.
Are there likely to be further problems if the names contain other characters that have special meaning in Excel?
I could also refer to the columns by address instead of name. Would that work with the current row '#' notation?
Excel version:14.0.7188.5002
I hear you when you say the naming convention is "not under my control". This really puts you in a bind when anything can be pumped into your code.
Sadly, the only solution is to scrub the input when they finally hand it over to you. This involves you having to make your own vba function that takes in a string and returns a string that has special characters removed (or replaced with something else).
In your case, you are going to have to scrub the data in possibly two places.
First, you will need to change all the column names so they don't have special characters in them. You'll need to access each name and send it through the 'scrub' function and then replace the name with the scrubbed name.
Second, when someone inputs a column name for your AGGREGATE, you'll need to capture that input into a string variable and then pass that through the 'scrub' function. Then you'll need to validate that the input they gave you matches up with a valid column name. If it's not valid, send them an error message asking them to enter a valid name or to cancel out.
After you have valid values for foo and bar, you can add them to your AGGREGATE function and let it execute.
If you can't scrub/change your column names, then you'll have to make a list of scrubbed column names and associate them with the column address. Then when you get your input, scrub it, and then match to the list to grab the correct address. Then you can use hard addresses instead of variable naming schemes.
It's a lot of work. But it's necessary when you have naming conventions that are not under your control.
The other answers and comments put me on the right track:
Function escapedColumnName(columnName As String) As String
columnName = Replace(columnName, "'", "''")
columnName = Replace(columnName, "#", "'#")
columnName = Replace(columnName, "[", "'[")
columnName = Replace(columnName, "]", "']")
escapedColumnName = columnName
End Function

IntelliJ IDEA & AppCode live template nested variable issue

I have this snippet that are used in textmate:
var ${0:name} = ${1:"${2:value}"};
When this snippet get called, first the name will be selected and I have a chance to type something and change the variable name. Press TAB again it will select "value", in this case if my value is a number (the quotes is not required) I can start to type a number and overwrite "name". If my value is a string, I can press TAB again and it will select name (no quotes), I can actually type something and they will appear in the quotes. I want to know if this is doable in JetBrains software like Intellij IDEA and AppCode. I've tried but failed. Below is my code for JetBrains software.
var $name$ = "$value$";
I don't know how to give me a chance to select "value" instead of directly selecting value. Anyone can point me to the right direction? Thanks.
I don't think you can do exactly what you want. I got fairly close using this template:
var $name$ = $QUOTE$ $value$ $QUOTE$;
Then in "Edit variables" I set the expression for QUOTE to be "\"" and moved value above QUOTE.
This allows you to type the name, as you wanted, and tab next to value, where you can enter a string or a number. The next tab will highlight the first quote, which you can delete if you had a number - this will also delete the trailing quote.
However this is not exactly what you wanted, as the value inside the quotes, should you leave them there, has spaces either side. This is because what I really wanted was
var $name$ = $QUOTE$$value$$QUOTE$;
but if you put two variables next to each other like this, IntelliJ gets very confused.
I know this isn't the answer, but maybe it has you thinking about slightly different approaches to the problem.

How do I keep the apostrophes when importing csv to sqlite

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.