下载数据

csv 文件格式

 分析 CSV 文件头

# CSV模块
import csv

filename = 'test01.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)   # 读取表头
    print(header_row)
    

打印文件头及其位置

# CSV模块
import csv

filename = 'test01.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)   # 读取表头

    # 打印文件头及其位置
    for index, column_header in enumerate(header_row):
        # 读取表头及其元素位置
        print(index, column_header)
        
    

提取并读取数据

# CSV模块
import csv

filename = 'test01.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)   # 读取表头

    highs = []
    for row in reader:
        highs.append(row[1]) # 第二列

    print(highs)
    

绘制表格

 

在表格中添加日期

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
猜你喜欢
  • 2021-04-07
  • 2021-09-27
  • 2021-09-18
  • 2021-11-23
  • 2021-10-07
相关资源
相似解决方案