fix: improve ai table file handling
This commit is contained in:
@@ -92,12 +92,17 @@ func parseXLSX(path string) (Profile, error) {
|
||||
}
|
||||
defer f.Close()
|
||||
for _, sheet := range f.GetSheetList() {
|
||||
rows, err := f.GetRows(sheet)
|
||||
iter, err := f.Rows(sheet)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
cleaned := make([][]string, 0, min(len(rows), maxRows))
|
||||
for _, row := range rows {
|
||||
cleaned := make([][]string, 0, maxRows)
|
||||
for iter.Next() {
|
||||
row, err := iter.Columns()
|
||||
if err != nil {
|
||||
_ = iter.Close()
|
||||
return Profile{}, err
|
||||
}
|
||||
if emptyRow(row) {
|
||||
continue
|
||||
}
|
||||
@@ -106,6 +111,9 @@ func parseXLSX(path string) (Profile, error) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err := iter.Close(); err != nil {
|
||||
return Profile{}, err
|
||||
}
|
||||
if len(cleaned) > 0 {
|
||||
return profileRows(cleaned), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user