Display each digit in a separate column in a row in Google Sheets - regex

I have a column of data in binary values and I would like to split each digit of the number in the column into different cells across a row. How would I go about doing so? I saw the split function, but could not get it to work. https://support.google.com/docs/answer/3094136?
One of my example inputs:
1000111110100101111011110
1000110000100101000010000

try with this (you just change A2 to your cell):
=transpose(arrayformula(mid(A2,row(A1:offset(A1,len(A2),0)),1)))
For some rows (I limited text length with 30 char, you can change it):
=transpose(ARRAYFORMULA(mid(transpose(query(arrayformula(if(isnumber(A1:A)=true ,text(A1:A,"0"),A1:A)),"Select Col1 where Col1<>''")),row(A1:A30),1)))

try:
=ARRAYFORMULA(REGEXEXTRACT(A1:A, REPT("(.)", LEN(A1:A))))

Related

Google Sheets - IF columns contains text and another columns contains number return total value of number column

I am trying to see if I am able to get the hours from one column only if it matches a word that is another column.
For example in the sheet link attached, if the word is Operations (Column A) I want to get the sum of all the hours (Column B) that correlate with that word.
https://docs.google.com/spreadsheets/d/1-1QCZsNTZ5xDcDryv8qg0YPtsoY3Erjz7ZNGUXds7HY/edit
Hope this makes sense.
Thanks in advance.
you can use:
=SUM(IFNA(FILTER(B:B,A:A=E1)))
OR
=SUMIF(A:A,E1,B:B)
Cell E1 has the word selection in the sample here

How to add leading Zero's to make location number in Power BI so it returns 3 digit #

Loc1= FORMAT('Table'[LOC],"000") Any suggestion would be helpful? The original Column LOC is a text field with returns 3 characters with leading Zero's. I need it in numeric form to be able to join and use it in calculated columns.
Found a work around to fix my problem, I came up with a solution to keep Loc column as text and add concatenate column with Business Unit ID and Loc & convert concatenated col to numeric field so I can use for filtering and joining.

Extract multiple substrings of numbers of a specific length from string in Google Sheets

I'd need to split or extract only numbers made of 8 digits from a string in Google Sheets.
I've tried with SPLIT or REGEXREPLACE but I can't find a way to get only the numbers of that length, I only get all the numbers in the string!
For example I'm using
=SPLIT(lower(N2),"qwertyuiopasdfghjklzxcvbnm`-=[]\;' ,./!:##$%^&*()")
but I get all the numbers while I only need 8 digits numbers.
This may be a test value:
00150412632BBHBBLD 12458 32354 1312548896 ACT inv 62345471
I only need to extract "62345471" and nothing else!
Could you please help me out?
Many thanks!
Please use the following formula for a single cell.
Drag it down for more cells.
=INDEX(TRANSPOSE(QUERY(TRANSPOSE(IF(LEN(SPLIT(REGEXREPLACE(A2&" ","\D+"," ")," "))=8,
SPLIT(REGEXREPLACE(A2&" ","\D+"," ")," "),"")),"where Col1 is not null ",0)))
Functions used:
QUERY
INDEX
TRANSPOSE
IF
LEN
SPLIT
REGEXREPLACE
If you only need to do this for one cell (or you have your heart set on dragging the formula down into individual cells), use the following formula:
=REGEXEXTRACT(" "&N2&" ","\s(\d{8})\s")
However, I suspect you want to process the eight-digit number out of all cells running N2:N. If that is the case, clear whatever will be your results column (including any headers) and place the following in the top cell of that otherwise cleared results column:
=ArrayFormula({"Your Header"; IF(N2:N="",,IFERROR(REGEXEXTRACT(" "&N2:N&" ","\s(\d{8})\s")))})
Replace the header text Your Header with whatever you want your actual header text to be. The formula will show that header text and will return all results for all rows where N2:N is not null. Where no eight-digit number is found, null will be returned.
By prepending and appending a space to the N2:N raw strings before processing, spaces before and after string components can be used to determine where only eight digits exist together (as opposed to eight digits within a longer string of digits).
The only assumption here is that there are, in fact, spaces between string components. I did not assume that the eight-digit number will always be in a certain position (e.g., first, last) within the string.
Try this, take a look at Example sheet
=FILTER(TRANSPOSE(SPLIT(B2," ")),LEN(TRANSPOSE(SPLIT(B2," ")))=8)
Or this to get them all.
=JOIN(" ,",FILTER(TRANSPOSE(SPLIT(B2," ")),LEN(TRANSPOSE(SPLIT(B2," ")))=8))
Explanation
SPLIT with the dilimiter set to " " space TRANSPOSE and FILTER TRANSPOSE(SPLIT(B2," ") with the condition1 set to LEN(TRANSPOSE(SPLIT(B2," "))) is = 8
JOIN the outputed column whith " ," to gat all occurrences of number with a length of 8
Note: to get the numbers with the length of N just replace 8 in the FILTER function with a cell refrence.
Using this on a cell worked just fine for me:
(cell_with_data)=REGEXEXTRACT(A1,"[0-9]{8}$")

Google Sheets ArrayFormula to get INITIALS of arbitrary length name

Sample sheet.
As the title says, given a column of arbitrary number of words of arbitrary length, Want a single ArrayFormula to get the first letters of all words in the said column.
I have tried two methods, seen in sample sheet.
1) Using SPLIT and ARRAYFORMULA, can get it one cell but cannot extend down column.
2) Using 2 REGEXEXTRACT, can get for first 2 initials and extend down
But is it possible to get for arbitrary number of words for whole column using ArrayFormula.
Is it possible to use REGEXEXTRACT to return the first letters of many words?
This replaces every word with the captured first letter
=ARRAYFORMULA(UPPER(REGEXREPLACE(A1:A6,"(\w)\S*\s?","$1")))

Regular Expression to break row with comma separated values into distinct rows

I have a file with many rows. Each row has a column which may contain comma separated values. I need each row to be distinct (ie no comma separated values).
Here is an example row:
AB AB10,AB11,AB12,AB15,AB16,AB21,AB22,AB23,AB24,AB25,AB99 ABERDEEN Aberdeenshire
The columns are comma separated (Postcode area, Postcode districts, Post town, Former postal county).
So the above row would get turned into:
AB AB10 ABERDEEN Aberdeenshire
AB AB11 ABERDEEN Aberdeenshire
AB AB12 ABERDEEN Aberdeenshire
...
...
I tried the following but it didn't work...
(.+)\t(([0-9A-Z]+),)+\t(.+)\t(.+)
I agree that RegEx are not be the best way but this should work hopefully if that's all you have available to you. (Done repeatedly until there are no more matches)
Edit
Updated with the OP's final solution from the comments.
Find: (.+)\t([^,\s]+),([^\t]+)\t(.+)
Replace: \1\t\2\t\4\r\1\t\3\t\4
I agree with stakx that this doesn't sound like a good place for regexes.
I would write a small program instead which read each line, split the line into columns, split each relevant column into a list of values, and then iterated over all combinations of those, outputting a line each time.
Assuming it's only that one column which can have multiple tokens, it would basically look like this:
while not InputFile.EndOfFile:
line = InputFile.readline();
columns = line.split('\t'); //Assuming 1-based array, so indexes 1-4
col2values = columns[2].split(',');
for each value in col2values:
OutputFile.WriteLine(columns[1]+'\t'+value+'\t'+columns[3]+'\t'+columns[4]);
If multiple columns can have multiple values, simply put another loop inside the for each.