我正在对我的语料库中的单词列表进行拼写更正。这花费了很长时间,而且我的连接中断了。为了防止这种情况,我想逐行处理语料库,并将输出保存在数据框中,然后每次将其导出。
我试图切片数据并导出输出,但是只有在所有行上进行迭代时,才导出输出
假设我的数据有100行,应该每10行输出一次
var data_obj_arr = [{"Size": "<1000", "Type": "Detached", "Location": "Northern", "Configuration": "Downflow", "Age": "Built Before 1980", "Collection_Name": "test"}, {"Size": "<1000", "Type": "Detached", "Location": "Northern", "Configuration": "Downflow", "Age": "Built Before 1980", "Collection_Name": "test"}, {"Size": "<1000", "Type": "Detached", "Location": "Northern", "Configuration": "Downflow", "Age": "Built Before 1980", "Collection_Name": "test"}]
function updateChosenOption(category_choice, category) {
var arr = [];
for (let i in data_obj_arr) {
if (data_obj_arr[i][category] === category_choice) {
arr.push(data_obj_arr[i]["Collection_Name"]);
}
}
console.log(`Array: ${arr}`);
// v -- needs to be a regular funtion
var results = data_obj_arr.filter(function(el) {
return el[this.curr_category] === category_choice
}, {curr_category: category}) // < -- to pass in this
.map(el => el["Collection_Name"]);
console.log(`Results: ${results}`);
}
updateChosenOption('Built Before 1980', 'Age')