Separating data from a single line in google sheets - google-sheets

Is there a way to separate a single line of text into different cells based on a character?
IE: This string needs to be separated - The first name is kar#, followed by a number. Is it possible to separate kar# and the number that follows, and for the remaining data. Like a find function for # and it returns data 1 from find and so on? Thanks! <3
kar# 1,910.0k|joule# 1,731.0k|miss# 1,672.1k|talli# 1,625.1k|butter# 1,591.8k| kulka# 1,278.3k|risin# 1,257.4k|robste# 1,171.4k|dub# 1,157.5k|ulfval# 1,071.5k| ayma# 1,007.6k|kakaro# 1,007.2k|smile# 993.0k|imba# 980.9k|mattyliciou# 965.3k| udi# 917.7k|mad# 910.4k|redbir# 830.2k|epi# 821.2k|sof# 804.1k| keato# 730.8k|kevy# 728.3k|mik# 690.3k|juru# 628.2k|nutz# 577.1k|

try:
=INDEX(SPLIT(FLATTEN(SPLIT(A1; "|")); " "))

Related

Filter data starts with character - Google Sheets

I have large set of data, and I want to filter the data which only start with certain character inside Query.
For example:-
AVTD1X4K1V0R01IA
AVTD1X4K1V0RXXF1
AVTD1X4K1V0RXXFA
AVTDMAIN1V0R03IA
AVTDMAIN1V0RXXFA
AWEWE23232323232
BLIVSE20122014X1
CA100U50VXSRCCCF
CA330U50VXSRCBCF
CA47UX63VXSRBBCX
In that data If I want to get starting with 'A' codes.
Thanks in advance
You can use match clause.
It will look like this based on your example
QUERY(A1:A11,"where A matches 'A.*'")
Change reference accordingly!
Try
=query(A:A,"select A where A like 'A%' ")

Replacing empty cells in a variable with values from another

I have a dataset with a number of columns. Two of them are practically the same however in variable column 1 there are string data that I would like to extract and replace in empty cells of variable column 2.
I tried using the syntax
If
variable_2 = "".
Compute variable_1 = variable_2.
End If
But do not get anything. Please, could someone help with this?
Much appreciated.
This should be either
if var2="" var2=var1.
(no period after the condition, no "end if")
OR
do if var2="".
compute var2=var1.
end if.
(this is a "do if" and not just an "if" - enables you to add commands after the condition, and not needed here).
In any case, if variable_2 is empty you want to run variable_2=variable_1 and not the reverse.

GSheets - How to query a partial string

I am currently using this formula to get all the data from everyone whose first name is "Peter", but my problem is that if someone is called "Simon Peter" this data is gonna show up on the formula output.
=QUERY('Data'!1:1000,"select * where B contains 'Peter'")
I know that for the other formulas if I add an * to the String this issue is resolved. But in this situation for the QUERY formula the same logic do not applies.
Do someone knows the correct syntax or a workaround?
How about classic SQL syntax
=QUERY('Data'!1:1000,"select * where B like 'Peter %'")
The LIKE keyword allows use of wildcard % to represent characters relative to the known parts of the searched string.
See the query reference: developers.google.com/chart/interactive/docs/querylanguage You could split firstname and lastname into separate columns, then only search for firstnames exactly equal to 'Peter'. Though you may want to also check if lowercase/uppercase where lower(B) contains 'peter' or whitespaces are present in unexpected places (e.g., trim()). You could also search only for values that start with Peter by using starts with instead of contains, or a regular expression using matches. – Brian D
It seems that for my case using 'starts with' is a perfect fit. Thank you!

Joining more than two WHERE statements in Query Language

So I am trying to use a simple QUERY function in Google Sheets where I want to select based on TWO parameters. Simple logic, and documentation says use the AND operator. The problem is I am searching for text via Cell Reference.
So here is my function
=QUERY(A1:D6,"select A where C='" &K1&'"" & "and D='" &K2"'")
Unfortunately it throws up an ERROR. I understand that Cell References that are text based need to be in single quotes (which themselves need to be in double quotes), but I am unable to join two WHERE statements.
What is the right syntax for this?
Very close indeed, please try:
=query(A1:D6,"select A where C='"&K1&"' and D='"&K2&"' ")
Welp! I was missing an concatenation symbol (&) at the end of the final cell reference K2.
=QUERY(A1:D6,"select A where C='" &K1&'"" & "and D='" &K2&"'")

Suppress delimiters in Ruby's String#split

I'm importing data from old spreadsheets into a database using rails.
I have one column that contains a list on each row, that are sometimes formatted as
first, second
and other times like this
third and fourth
So I wanted to split up this string into an array, delimiting either with a comma or with the word "and". I tried
my_string.split /\s?(\,|and)\s?/
Unfortunately, as the docs say:
If pattern contains groups, the respective matches will be returned in the array as well.
Which means that I get back an array that looks like
[
[0] "first"
[1] ", "
[2] "second"
]
Obviously only the zeroth and second elements are useful to me. What do you recommend as the neatest way of achieving what I'm trying to do?
You can instruct the regexp to not capture the group using ?:.
my_string.split(/\s?(?:\,|and)\s?/)
# => ["first", "second"]
As an aside note
into a database using rails.
Please note this has nothing to do with Rails, that's Ruby.

Resources