CSV files not being displayed correctly, when field count does not match between header and value lines #7231

Closed
opened 2025-11-02 07:20:19 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @nils91 on GitHub (Apr 22, 2021).

Description

CSV files that contain contact information (exported as 'Outlook CSV' from Google) are not being displayed correctly, only the header is shown in the table. Viewing the file as text in Gitea shows the full file. As far as i can tell, those files are regular .csv files (not sure actually, see next sentence), libreoffice for example displays them just fine. The problem seems to be that Google adds an extra comma to the end of each value line, which is not present in the header.

Screenshots

csv_contact_table_ng
csv_contact_table

Originally created by @nils91 on GitHub (Apr 22, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.13.6 and 1.15.0+dev-172-g445e47b69 - Git version: 2.7.4 - Operating system: Ubuntu 16.04, running gitea from binary (as service), downloaded <!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package --> <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] Yes: https://try.gitea.io/nils91/csv_file_display_test/src/branch/master/csv_contact_uploaded.csv (CSV contact) https://try.gitea.io/nils91/csv_file_display_test/src/branch/master/csv_extra_comma_value.csv (extra comma in value line, cause) - [ ] No ## Description CSV files that contain contact information (exported as 'Outlook CSV' from Google) are not being displayed correctly, only the header is shown in the table. Viewing the file as text in Gitea shows the full file. As far as i can tell, those files are regular .csv files (not sure actually, see next sentence), libreoffice for example displays them just fine. **The problem seems to be that Google adds an extra comma to the end of each value line, which is not present in the header.** ## Screenshots ![csv_contact_table_ng](https://user-images.githubusercontent.com/7298243/115710402-9a953100-a372-11eb-9830-13d554fef38d.PNG) ![csv_contact_table](https://user-images.githubusercontent.com/7298243/115708645-8ea86f80-a370-11eb-8c79-aceb44404953.PNG)
GiteaMirror added the issue/not-a-bug label 2025-11-02 07:20:19 -06:00
Author
Owner

@lunny commented on GitHub (Apr 22, 2021):

First line has 88 columns but second has 89 columns on csv_contact_uploaded.csv

@lunny commented on GitHub (Apr 22, 2021): First line has 88 columns but second has 89 columns on `csv_contact_uploaded.csv`
Author
Owner

@nils91 commented on GitHub (Apr 22, 2021):

For reference, heres RFC 4180 on CSV:

  1. Within the header and each record, there may be one or more
    fields, separated by commas. Each line should contain the same
    number of fields throughout the file. Spaces are considered part
    of a field and should not be ignored. The last field in the
    record must not be followed by a comma.

It seems the exported file is not following CSV as outlined by RFC 4180.

@nils91 commented on GitHub (Apr 22, 2021): For reference, heres [RFC 4180](https://tools.ietf.org/html/rfc4180#section-2) on CSV: > 4. Within the header and each record, there may be one or more fields, separated by commas. Each line should contain the same number of fields throughout the file. Spaces are considered part of a field and should not be ignored. The last field in the record must not be followed by a comma. It seems the exported file is not following CSV as outlined by RFC 4180.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7231