I'm grouping text strings using the following line of code:
array_join(array_agg(distinct rd.user_id),'","') as Users_id
I'm getting the following results:
Users_id
US1234
US1234","US2345","US1254
But I need the following instead (All strings between quotation marks and comma separated)
Users_id
"US1234"
"US1234","US2345","US1254"
I guess it should be fairly simple but cannot make it work.
Any help would me much appreciated.
Thanks
JQ
Related
I am having trouble to loop through a file day.txt containing XPaths.
For example: I already tried to triple quote in the file like this:
"""//[#id="frm"]/div[4]/div/div[1]/div[1]/div[2]/div/div[1]/div/div[2]"""
but it's not working.
The error is
SyntaxError:
Failed to execute 'evaluate' on 'Document':
The string '"""//*[#id="frm"]/div[4]/div/div[1]/div[1]/div[2]/div/div[2]/div[2]/div[3]/div/div/div[2]/table/tbody/tr[1]/td[7]/span"""
'
is not a valid XPath expression.
Any help is welcome!
dates = open("days.txt")
for date in dates:
date.strip()
driver.find_element_by_xpath(date).click()
You shouldn't need any quotes around the lines in the txt file. If your XPath locators contain double quotes ("), you will need to replace them all with single quotes (') before using them. If you google replacing characters in a string in python, you'll find some example code.
NOTE: Locators that contain that many levels are very brittle. You really need to handcraft those locators to make them much shorter.
I am trying to extract id of Android app from its url but getting extra characters.
Using replace function in sql server, below are two sample urls:
https://play.google.com/store/apps/details?id=com.flipkart.android&hl=en com.flipkart.android
https://play.google.com/store/apps/details?hl=en_US&id=com.surveysampling.mobile.quickthoughts&referrer=mat_click_id%3Df1901cef59f79b1542d05a1fdfa67202-20150429-5128 en_US&id=com.surveysampling.mobile.quickthoughts&r
I am doing this right now:
SELECT
SUBSTRING(REPLACE(PREVIEW, '&hl=en',''), CHARINDEX('?', PREVIEW) + 4 , 50)
FROM OFFERS_TABLE;
But for 1st I am getting com.flipkart.android which is correct, but for 2nd I am getting en_US&id=com.surveysampling.mobile.quickthoughts&r.
I want to remove en_US&id from starting of it and &r from its end.
Can someone help me with any post or url from where I can refer?
What you are actually trying to do is extract the string preceded by id= until the & is found which is separator for variables in URL. Taking this condition I came up with following regex.
Regex: (?<=id=)[^&]*
Explanation: It uses the lookbehind assertion that is the string is preceded by id= until the first & is found.
Regex101 Demo
It seems like you've made some assumptions of lengths. The the &r is appearing because that is 50 characters. You are also getting the en_US because you assumed 4 characters at the beginning but your second string has more. Perhaps you can split on & and then look for the variable that begins with id=.
it seems like a function like this would help.
http://www.sqlservercentral.com/blogs/querying-microsoft-sql-server/2013/09/19/how-to-split-a-string-by-delimited-char-in-sql-server/
I was not able to solve this by myself so I hope I didn't miss any similar post here and I'm not wasting your time.
What I want is to identify (get a list) of all strings used in SQL Server code.
Example:
select 'WordToCatch1' as 'Column1'
from Table1
where Column2 = 'WordToCatch2'
If you put above code to SSMS all three words in apostrophes will be red but only words 'WordToCatch1' and 'WordToCatch2' are "real" strings used in code.
My goal is to find all those "real" strings in any code.
For example if I will have stored procedure 10k rows long it would be impossible to search them manually so I want something what will find all those "real" strings for me and return a list of them or something.
Thanks in advance!
The trouble is, Column1 is nothing particular different compared to WordToCatch1 and WordToCatch2 - not unless you parse the SQL yourself. You could modify your query to take the quotes away from Column1 and it will show up coloured black.
I guess a simple regex will show up all identifiers after an AS keyword, which would be easier than fully parsing SQL, if all the unwanted strings are like that, and its not just an example.
I have a CSV file I am importing through SSIS.Below is an sample of the data in my file
"MEM1001","OTHER","P" ,20101001,20781231,,20781231,20101001,
"Medic","General >21" ,
"A100100" ,"2210",20101001,20781231
I have added , as column delimiter and " as Text Qualifier in the connection manager.
But columns like "P" ,"Medic","General >21" ,"A100100" , are still coming enclosed with double quotes when I preview the data while rest the of the string columns are coming without double quotes.
I am guessing it has something to do with the spaces after the quotes.
Can somebody explain why this is happening and how can i make this columns to come without double quotes while importing the data from file to table.
I just stumbled across this post, I had the same issues, I was trying around and could not find any other solution.
The text qualifier " only works in csv files, when the quote is directly after the colon, no space after the colon and the text identifier/qualifier. I have no idea why.
If you aren't able to fix the input data, an option would be to create a derived column and to replace the double quotes.
This worked for me:
How to replace double quotes in derived column transformation?
Trim(REPLACE(COLA, "\"", ""))
You should also add the Trim(), otherwise you have empty spaces before and maybe after the word. This could be problematic in a merge join (in my case it was).
I don't know why this extra spaces cause this issue.
Here is what I would do. It may not be the best idea, but it should work.
You will need to add script task before data flow task that would replace all " ," and ", " to ",".
Thank you
Why not just go to the Connection Manager for that csv file, click on Columns, and under the Column delimiter box just enter a space followed by a comma? Worked for me.
I have created a db called AllWords.db in sqlite that contains a list of all english words (count:172820). When I issue a select all query, it returns a list of all 172820 words. Also, when I print the count of the table words like this :
SELECT COUNT(*) FROM words;
the output is 172820, so the database clearly has all the words included in it. However, when I try to check if a word exists (the only thing I'll want to do with this database), it doesn't print anything :
SELECT * FROM words WHERE word="stuff";
returns nothing.
The database is a single table with the only column being 'words', which has all the words as rows. Any help would be greatly appreciated, thanks.
Just to be sure you use a word in your database, look into your table with
select * from words limit 10
house
stuff
tree
...
and then select with one of the words you see
select * from words where word = 'stuff'
Edit: fixed where clause according to #MichaelEakins
Edit2: Unfortunately there's no difference between single and double quotes in this case, see SQL Fiddle
Answering my own question because I figured out what was wrong. To populate the table, I had written a python program to parse a file called words.txt (all words, separated by newlines), into sqlite. My problem was the query turned into :
INSERT INTO WORDS VALUES('englishWord\n')
And that messed up the database. I fixed that and it started to work, thanks to #ScoPi for the hint with using LIKE, it helped me figure out that there was a stray newline character.