Forum Discussion

Boricuanet's avatar
Boricuanet
Frequent Visitor
4 years ago
Solved

Validate data when importing file

Hello dear community,

 

I have the following problem and also query.

How can I validate the data before extracting the data, check the file(source) contains information. To avoid errors(attached image).
For example: validate if report.html has data. If NO data, create a table with two columns, one row with zero values.

(I know that the error is due to not finding the "Computer" column and it will never exist when there is no data in the html file).

 

 

 

let
    Origen = Web.Contents("https://site.com/report.html"),
    #"Tabla extraída a partir de HTML" = Html.Table(Origen, {{"Column1", "TABLE:nth-child(91) > * > TR > :nth-child(1)"}, {"Column2", "TABLE:nth-child(91) > * > TR > :nth-child(2)"}, {"Column3", "TABLE:nth-child(91) > * > TR > :nth-child(3)"}, {"Column4", "TABLE:nth-child(91) > * > TR > :nth-child(4)"}}, [RowSelector="TABLE:nth-child(91) > * > TR"]),
    #"Encabezados promovidos" = Table.PromoteHeaders(#"Tabla extraída a partir de HTML", [PromoteAllScalars=true]),
    #"Tipo cambiado" = Table.TransformColumnTypes(#"Encabezados promovidos",{{"Computer", type text}, {"Number", Int64.Type}, {"%", Int64.Type}, {"", type text}}),
    #"Columnas quitadas" = Table.RemoveColumns(#"Tipo cambiado",{""}),
    #"Tipo cambiado1" = Table.TransformColumnTypes(#"Columnas quitadas",{{"Number", Int64.Type}})
in
    #"Tipo cambiado1"

 

 

 

 

 

 


Appreciated Any guidance