Skip to content

List import count off by one. #2541

@howardah

Description

@howardah

Version:

  • listmonk: [eg: v5.0.1]
  • OS: [Ubuntu Server]

Description of the bug and steps to reproduce:
When importing a csv list, it seems that the total count is one less than it should be. Which produces an inaccurate import screen. In the screenshot, for example, it shows 6/5 imported and 120%.

It looks like the problem comes from the countLines function in internal/subimporter/importer.go which produces a total count by counting the line breaks (\n) in the csv. This called in the LoadCSV function of the same file and one is removed from the total in order to exclude the header. This works assuming that the csv includes a trailing line break but doesn't whenever there is no trailing line break (as in the csv used in my example).

It's a small and purely aesthetic issue, but I would be happy to open a small PR to patch the countLines function to slightly more accurately count the lines by checking if there are trailing line breaks or not!

Screenshots:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions