Forum Discussion

Oguy's avatar
Oguy
Regular Visitor
1 year ago
Solved

Get Data From Text file- Text file which start by "PK" do not work.

When a text file start by PK. The options do not displayed. I don't figure why.

Detail :

Case 1 file start with "PK" Don't work

My file :

 

Loading in power BI Throught Get Data -> Txt file/csv

There is a problem because it does not display any options.

Case 2 file start by "P" Work

My file :

Loading in power BI Throught Get Data -> Txt file/csv:

In that case, no problem and the option menu is displayed.

  • PK is the beginning of a zip file (xlsx files are actually zip files), which you can check in section 4.2 of the .ZIP File Format Specification.

    Why does Power Query do this? I guess it's to prevent some people from accidentally changing .xlsx files to .csv files. In fact, if you change the suffix of the .xlsx file to the suffix of the .csv file (change ".xlsx" to ".csv"), Excel can still open it correctly.

    Back to the real world, only regions that only use English letters have a small chance of encountering this problem (so, I guess Microsoft will not fix it), because the beginning of "PK" in many regions (such as Chinese and Russian) uses multi-byte characters, and it is difficult to encounter "PK".

    Solution to the problem: manually write the expression to import csv/txt files, or do not use ANSI encoding (I reproduced your problem using code page windows-1250).

6 Replies

  • are you sure these are text files?  PK are the initials of the creator of the ZIP file format...

  • Anonymous's avatar
    Anonymous
    Not applicable

    Try clicking on that image of the txt file in the window.

     

    --Nate

  • Oguy's avatar
    Oguy
    Regular Visitor

    Yes i'm sure. I created them from scratch in .txt. Super interesting, so it may be a Power BI detection bug. 

      • Oguy's avatar
        Oguy
        Regular Visitor

        On my version of power bi : 2.138.782.0 64-bit (novembre 2024

        i go directly there inside my PK file i try with your : it's :

        "PK file"

         

        Thank you for your investigation. 

  • PK is the beginning of a zip file (xlsx files are actually zip files), which you can check in section 4.2 of the .ZIP File Format Specification.

    Why does Power Query do this? I guess it's to prevent some people from accidentally changing .xlsx files to .csv files. In fact, if you change the suffix of the .xlsx file to the suffix of the .csv file (change ".xlsx" to ".csv"), Excel can still open it correctly.

    Back to the real world, only regions that only use English letters have a small chance of encountering this problem (so, I guess Microsoft will not fix it), because the beginning of "PK" in many regions (such as Chinese and Russian) uses multi-byte characters, and it is difficult to encounter "PK".

    Solution to the problem: manually write the expression to import csv/txt files, or do not use ANSI encoding (I reproduced your problem using code page windows-1250).