尝试将40k个文件从nodejs和aws-sdk上传到s3我确实承诺每件事代码都可以正常工作直到5800条记录,但是在此之后失败,其余文件没有上传,任何人都可以帮忙为什么会这样或我必须使用一些其他方法还是需要更新我的代码?
这是我的代码
from sklearn.feature_extraction.text import CountVectorizer
from gensim import matutils
from gensim.models.ldamodel import LdaModel
text = ['computer time graph', 'survey response eps', 'human system computer','machinelearning is very hot topic','python win the race for simplicity as compared to other programming language']
# suppose this are the word that you want to be used in your vocab
vocabulary = ['machine','python','learning','human', 'system','hot','time']
vect = CountVectorizer(vocabulary = vocabulary)
x = vect.fit_transform(text)
feature_name = vect.get_feature_names()
# now you can use matutils helper function of gensim
model = LdaModel(matutils.Sparse2Corpus(x),num_topic=3,id2word=dict([(i, s) for i, s in enumerate(feature_name)]))
#printing the topic
model.show_topics()
答案 0 :(得分:3)
与其这样做,不如采用更安全的方法,而是使用aws cli打开一个子进程。
使用aws s3 sync
或copy
命令执行此操作。
与强力方法(例如for循环内的调用)相比,它会更快,更能提供故障预防。
如果所有文件都不在单个目录中,也不在一定数量的目录中。您应该生成要上传文件的路径列表。将该文本文件写入磁盘。使用aws cli使用文本文件中的路径上载或下载。