2016-06-08 77 views

回答

0

以下是我的解決方案:

excel_data = request.get_records(field_name='file') 
# Example for excel_data: [{「k1」: 「v1」, 「k2」: 「v2」, 「k3」: 「v3"}, 
#       {「k1」: 「」, 「k2」: 「」, 「k3」: 「"}] 
not_null_line_data = [] 
for d in excel_data: 
    if all(map(lambda x: x == '', d.values())): 
     continue 
    not_null_line_data.append(d) 
# not_null_line_data: 
# [{「k1」: 「v1」, 「k2」: 「v2」, 「k3」: 「v3"}] 

Github的燒瓶Excel的問題:How to ignore blank lines with flask-excel when import from xlsx?