60262186
Lok Sze Decoration Engineering Limited
Flat C7, 5/F, Tung Lee Factory Building, 9 Lai Yip Street, Kwun Tong, Kowloon

  • 中文 (香港)
  • English
  • Ethereum: Pandas read_excel doesn’t read certain xlsx files, returns empty dataframe

    Ethereum: Pandas can’t read XLSX files from Binance Trade Exports

    As a trader, simple importing and analyzing financial data is essential for making sound decisions. Recently, I have encountered a problem where Pandas could not read certain .xlsx files from exporting binance.com. This problem applies not only to me but also to other users who rely on this service.

    The problem: Pandas can’t read XLSX files

    To troubleshoot the problem, I checked Nic Scorazzos’s answer to a similar question, and noticed that you mentioned that using “Read_excel” does not work due to the limitations of reading certain .xlSX files. Specifically, he pointed out that some files in Binance trading exports are too complex or have special formatting problems that make them unfit for “Read_excel”.

    Solution: The pandas.read_csv () instead of use **

    After trying different solutions and consultation with other users, I realized that using pandas.read_csv () (or any other CSV-based solution) can be a better approach to reading .xlsx files from Binance trading exports. The reason for this is that pandas can handle more complex data formats than "read_excel".

    Why does "read_csv"

    work

    In order to work for me and others, "Read_csv" does not require pandas to analyze the entire file, which can cause problems with the data or missing data. Instead, read the data in the "read_csv" pieces, allowing pandas to handle more complex data structures.

    Example Code: Read a .xlsx file usingread_csv

    Here's an example of a code detail that shows how to usepandas.read_csv ()to read Binance Trade exports:

    Python

    Import pandas as PD

    Load the csv file

    df = pd.read_csv (‘binance_trade_export.csv’)

    Can also use the ‘XLRD’ directory as an alternative solution (for files .xlsx)

    Import xlrd

    File_path = ‘binance_trade_export.xlsx’

    df = pd.read_excel (file_path)

    Print (df.head ())

    Print the first few lines of the data frame

    `

    Conclusion:

    In summary, while “Read_excel” does not work due to the formatting problems or complexity of certain binance trading export files, using “pandas.read_csv () (or other CSV-based solutions) is a viable alternative. This approach allows pandas to treat more complex data formats and reduce the likelihood of formatting errors.

    I hope this solution helps other users who are fighting .xxlsx files from Binance’s commercial exports!

    perpetual period