Repository navigation
Conversation
A CSV that starts with a blank line - the shape Excel and many exporters produce - lost the entire table: the blank line became the header, so the column width was 0, every cell was rendered as an empty string and the parser reported an empty document. A UTF-8 BOM survived the decode and ended up inside the first header cell instead. Skip the leading blank rows and strip the BOM before the table is built.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Observed
A CSV that starts with a blank line produces an empty document:
The same file parsed directly with
EscapedCSVConvertershows the shape of the problem:A UTF-8 BOM has the same root cause one row up — it is not stripped, so it lands inside the first header cell:
Expected
Both engines (
"",builtin,markitdown) route CSV through the same converter, so all three lose the table.Root cause
EscapedCSVConverter.convert()takesrows[0]as the header. A leading blank line parses as an empty row, sowidth = len(rows[0])is0,row[:0]is empty, and every rendered cell becomes an empty string — the document body ends up empty and DocReader reports "Parser returned empty content".The decode keeps a UTF-8 BOM, because
stream_info.charsetisutf-8(notutf-8-sig), so\ufeffbecomes part of the first header cell.Files exported by Excel, Numbers and many "download as CSV" endpoints start with a blank line and/or a BOM, so this drops real documents.
Fix
Strip the BOM before splitting the rows, and skip leading rows that have no non-blank cell, so the header is the first row that actually carries data. Rows after the header keep MarkItDown's existing width policy, including intentional blank cells.
Verification
The two new cases cover a leading blank line and a UTF-8 BOM, each across the three engines.