Read the XLSX and CSV tables

  • Install the third-party library first

— Press [win] + [R] — Enter CMD — [Enter] — PIP install –index-url pypi.douban.com/simple

Such as:

pip install –index-url pypi.douban.com/simple pandas

pip install –index-url pypi.douban.com/simple numpy

It is said that there are some defects in douban library, hen. This website is “mirror”, which is very suitable for most of me with limited network and distance.

Tsinghua university pypi.tuna.tsinghua.edu.cn/simple/

Ali cloud mirrors.aliyun.com/pypi/simple…

Pypi.mirrors.ustc.edu.cn/simple/ China university of science and technology

Douban (douban) pypi.douban.com/simple/

University of science and technology of China pypi.mirrors.ustc.edu.cn/simple/

If the installation is successful, the following information is displayed at the end:

Successfully installed Is followed by the name of the installed package

  • Enter the specific code:

    import pandas as pd
    
    # this SkillCraft1_Dataset. CSV and redwine.xlsx is the file name to read
    
    #header = 0 #header = 0 #header = 0 #header =1 #header =1 #header = 0 #header = 0
    
    The.py file is stored in the same path as the read file. df1 = pd.DataFrame(pd.read_csv(r'C:\Users\Administrator\Desktop\xss\SkillCraft1_Dataset.csv', Header = 0)), that r is used to make Python recognize backslashes, or double backslashes C:\\Users\\Administrator\ Desktop\ XSS \\SkillCraft1_Dataset
    
    df1 = pd.DataFrame(pd.read_csv('SkillCraft1_Dataset.csv', header = 0))
    
    df2 = pd.DataFrame(pd.read_excel('redwine.xlsx'))
    
    # if you want to view the read result, then
    print(df2)
    Copy the code

    The header = 0,

    Header = 1.

  • Call it a day