Search code examples
google-sheetsgoogle-sheets-formulaarray-formulas

Limit the number of rows collected by IMPORTXML


Using IMPORTXML to scrape data from a site, it returns 5,000 rows of data. But my need is only the first 200 values. How do I limit import for this amount of rows?

I tried to do it as follows:

=QUERY(IMPORTXML("XXXXX","XXXXX"),"LIMIT 200")

But the first line joined the data from the first four lines. Like This:

Original     Expected     Result
     
A            A            ABCD
B            B            E
C            C            F
D            D            G
E            E            H
F
G
H
I
J
K
L

I need them all apart, each line below the other, nothing can join.


Solution

  • either use:

    =QUERY(IMPORTXML("ID", "XPath"), "limit 200", 0)
    

    or:

    =ARRAY_CONSTRAIN(IMPORTXML("ID", "XPath"), 200, 1)