ankitects / anki

Anki's shared backend and web components, and the Qt frontend
https://apps.ankiweb.net
Other
18.93k stars 2.14k forks source link

Issue with Importer Not Auto-Associating Tag Column #3561

Open cjdduarte opened 6 days ago

cjdduarte commented 6 days ago

I found a new issue while importing. My import file has 16 columns, with the last column containing the tags. However, the importer does not automatically associate the last field with the tag column, requiring me to select it manually each time.

The legacy import version used to associate this correctly, so it seems like there has been a change in how this is handled.

#separator:Comma
#notetype:TEC - PR (TELEGRAM)/ADMON
#html:true
"2042265_3","<a href=""https://www.tecconcursos.com.br/questoes/2042265"">2042265</a><font size=""1""> | 2022 | FCC | DPE AM | Planejamento e Controle de Estoques</font>","Administração de Recursos Materiais","O dimensionamento de estoque tem como principal função determinar a metragem ideal do local de armazenamento dos materiais.  ","ERRADO","C","O dimensionamento de estoque visa determinar a quantidade ideal de materiais a serem mantidos, não a metragem física do local de armazenamento.","","","","","","","","","Questões::Banca::FCC Questões::Ano::2022 Questões::Dificuldade::Sem_Classif Questões::Matéria::Administração_de_Recursos_Materiais::Planejamento_e_Controle_de_Estoques Questões::Tamanho::1.CURTO Questões::Tipo::TRANSFORMADA Questões::Alternativa::Errada"

image

image

abdnh commented 5 days ago

Looks like an off-by-one bug here. @RumovZ can you confirm?

https://github.com/ankitects/anki/blob/97e6b3d35b9ef541865a127fc094f521e43480d9/rslib/src/import_export/text/csv/metadata.rs#L500

RumovZ commented 5 days ago

@abdnh, yes, looks like it. Also, tags_column is set to max_field. This would seem more reasonable:

            for idx in (max_field + 1) as usize..=metadata.column_labels.len() {
                if !meta_columns.contains(&idx) {
                    metadata.tags_column = idx as u32;
                    break;
                }
            }
cjdduarte commented 4 days ago

Thanks !!!