使用sparkContext.wholeTextFiles读取文件非常慢

2024-05-19 03:38:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试从lichess数据库中读取PGN文件:https://database.lichess.org/。2013-01文件为16.1MB,读取时间约为8秒。2014-07的容量为176mb,16分钟后仍未完成。这是令人担忧的,因为我真的需要使用最新的27.3GB文件作为最终输出

def parse_game_file(game_file):
    from pyspark.sql import functions as F

    load_start = perf_counter()
    basefile = spark.sparkContext.wholeTextFiles(game_file, 10).toDF()
    load_stop = perf_counter()
    print("Time to load file:", round(load_stop - load_start,2))

df = parse_game_file('lichess_db_standard_rated_2014-07.pgn')

它挂在basefile = spark.sparkContext.wholeTextFiles(game_file, 10).toDF()行上

我在GoogleColab上运行这个程序,并且可以访问GoogleCloud平台,我认为这个平台会更快,但是我很惊讶GoogleColab不能处理一个只有176mb的文件

谢谢


Tags: 文件gameparsecounterloadstartsparkfile

热门问题