fix(csv): skip leading blank lines so they don't wipe the whole table#2137
Open
wajih-rathore wants to merge 1 commit into
Open
fix(csv): skip leading blank lines so they don't wipe the whole table#2137wajih-rathore wants to merge 1 commit into
wajih-rathore wants to merge 1 commit into
Conversation
A CSV whose first line is blank converted to an all-empty markdown table. csv.reader yields [] for the blank line, so rows[0] had zero columns. That empty row became the header, and every data row was then truncated with row[:len(rows[0])] == row[:0], silently dropping all the data. Skip leading empty rows before choosing the header. Adds a regression test fixture with a leading blank first line.
Author
|
@microsoft-github-policy-service agree |
|
clks vksd fs ,fçç,s v s fçdfps s,çdsç,v slkls |
|
fsdsm vkmonf smp vç vçs spmmel |
|
sdvnsd v msf lms,ldnksnv çsl |
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.
Fixes #2136.
A CSV whose first line is blank converts to an all-empty markdown table. Every row comes out as
| |and the data is silently lost.Cause:
csv.readeryields[]for the blank first line, sorows[0]is empty. The converter treatsrows[0]as the header (column count 0), then truncates every data row withrow[: len(rows[0])]->row[:0], dropping all the cells.Fix: drop leading empty rows before choosing the header row, so the first real row becomes the header. Added a test fixture with a leading blank line (
must_not_includechecks the| |empty-cell output no longer appears).Before:
After: