Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formula to convert matrix to rows in Google Sheets

I'm trying to concatenate rows of a matrix in a spreadsheet, which I've got from an importhtml call.

For example, if I have a 3x3 table:

A   B   C
D   E   F
G   H   I

I would like a command/function to convert it a row like so:

A B C D E F G H I

The idea is that each line will have a different html form which the same table/data is meant to be extracted. This cannot be done manually each time.

like image 815
Mefitico Avatar asked Nov 22 '25 20:11

Mefitico


2 Answers

replace A1:C3 with your IMPORTHTML formula:

=SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(A1:C3),,999^99)),,999^99), " ")

enter image description here


if it contains words / spaces:

=ARRAYFORMULA(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
 SUBSTITUTE(A1:C3, " ", CHAR(127))),,999^99)),,999^99), " "))

enter image description here

like image 186
player0 Avatar answered Nov 24 '25 10:11

player0


Nowadays, it's possible to convert a matrix to a line using the formula TOROW():

=TOROW(A1:C3)

The result will show the items in the following order

A1 A2 A3 B1 B2 B3 C1 C2 C3
like image 43
amkawai Avatar answered Nov 24 '25 11:11

amkawai