Forum Discussion

Mubarakbabs's avatar
Mubarakbabs
New Member
3 years ago
Solved

Disappearing rows in Power Query

I have some csv data. There are no missing values on my first column (ID column). However, when I load the data into Power Query, some of the values on the ID column disappear, and all the other colu...
  • foodd's avatar
    foodd
    3 years ago

    So, the bottom line is that when you use  a csv from this source, the file will need to be cleaned up.  This is not unexpected.   The file you shared started with 9705 rows, 32 rows removed (carrage return or similar character), and 9673 rows remaining.   It was in Column #2 that caused you issues, and where I deleted the character, and made a single line.    I used power query to import to both Excel and to Power BI without issue.  The following image gives you an idea what a bad row looks like:

     

     

    Copy this m-code into a blank query, update the source, and it should import without issue.  The fixed CSV is linked 

    for download as well:

     

    let
    Source = Csv.Document(File.Contents("C:\Users\user\Downloads\latest(fixed).csv"),[Delimiter=",", Columns=18, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Use First Row as Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Change Type" = Table.TransformColumnTypes(#"Use First Row as Headers",{{"id", Int64.Type}, {"name", type text}, {"host_id", Int64.Type}, {"host_name", type text}, {"neighbourhood_group", type text}, {"neighbourhood", type text}, {"latitude", type number}, {"longitude", type text}, {"room_type", type text}, {"price", Int64.Type}, {"minimum_nights", Int64.Type}, {"number_of_reviews", type text}, {"last_review", type text}, {"reviews_per_month", type number}, {"calculated_host_listings_count", Int64.Type}, {"availability_365", Int64.Type}, {"number_of_reviews_ltm", Int64.Type}, {"license", type text}})
    in
    #"Change Type"

     

    Link to download fixed CSV file:  https://gofile.io/d/Vl9AyQ