-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Also consider cellname as y #11
Conversation
WalkthroughThe update involves a consistent change across the Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (1)
- reader.go (4 hunks)
Additional comments: 2
reader.go (2)
138-142: The
cellName
function has been updated to increment bothx
andy
by 1 before converting them to a cell name. This change aligns with the pull request summary thatcellY
should be considered when determining the cell name. However, it's important to ensure that this increment does not cause any off-by-one errors elsewhere in the code, especially ifcellX
andcellY
are already at the correct values when passed to this function. If the increment is necessary due to theexcelize
library's coordinate system starting at 1, then this change is correct.199-210: The
nameType
function now acceptscellY
as a parameter, which is used when generating a unique name for a column if there is a collision in the header names. The logic checks if the header name already exists in thenameMap
and, if so, attempts to generate a new name usingcellName
. If there is an error, it appends the column index to the original name. This logic seems to handle name collisions, but it's important to ensure that thenameMap
is correctly populated and that thecellName
function is called with the correct coordinates. Additionally, the error handling should be reviewed to ensure that it is appropriate to continue processing with a modified name in case of an error incellName
.
} | ||
isFilter = true | ||
cellX-- | ||
cellY-- | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The decrement of cellY
has been removed in the latest commit, which suggests that the previous logic was incorrect. However, the increment of cellY
by 1 is not present in the provided code. If the intention was to increment cellY
, this change is missing and should be added to correctly reflect the pull request summary. If the increment is happening elsewhere in the code not shown in the diff, ensure that it is correctly implemented and tested.
Modified to stop decrementing when skip is set, because cellY was decreased by 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (1)
- reader.go (5 hunks)
Additional comments: 2
reader.go (2)
46-50: The decrement of
cellX
andcellY
has been removed, which aligns with the pull request summary stating thatcellY
should be incremented. However, the increment is not visible in the provided code. If the increment is intended to align with a 1-based index system, it should be added here unless it is handled elsewhere in the codebase.135-139: The
cellName
function correctly increments bothx
andy
by 1 before converting them to a cell name, which is consistent with the 1-based indexing used in spreadsheet software. This change is in line with the pull request summary.
r.names, r.types = nameType(rows[header], cellX, cellY, columnNum, opts.InHeader) | ||
rowNum := len(rows) - skip | ||
body := make([][]any, 0, rowNum) | ||
validColumns := make([]bool, columnNum) | ||
for i := 0; i < len(r.names); i++ { | ||
if r.names[i] != "" { | ||
validColumns[i] = true | ||
} else { | ||
name, err := cellName(cellX + i) | ||
name, err := cellName(cellX+i, cellY) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop on lines 92-99 is using cellX+i
and cellY
to generate cell names for columns without names. However, there is a potential off-by-one error because cellX
is decremented earlier in the code (lines 48-49), which is not reflected in the loop. This could lead to incorrect cell names if cellX
is not zero. Ensure that the logic correctly calculates the cell name based on the actual X and Y coordinates.
func nameType(row []string, cellX int, cellY int, columnNum int, header bool) ([]string, []string) { | ||
nameMap := make(map[string]bool) | ||
names := make([]string, columnNum) | ||
types := make([]string, columnNum) | ||
c := 0 | ||
for i := cellX; i < cellX+columnNum; i++ { | ||
if header && len(row) > i && row[i] != "" { | ||
if _, ok := nameMap[row[i]]; ok { | ||
name, err := cellName(cellX + i) | ||
name, err := cellName(cellX+i, cellY) | ||
if err != nil { | ||
names[c] = row[i] + "_" + fmt.Sprint(i) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nameType
function now includes cellY
as a parameter, which is consistent with the pull request summary. However, there is a potential issue with the error handling in the loop on lines 204-206. If an error occurs when calling cellName
, the code falls back to concatenating the row name with the index i
. This fallback does not seem to handle the error properly, as it does not log or return the error. It is important to handle errors appropriately to avoid silent failures and ensure that the caller is aware of any issues.
Summary by CodeRabbit
cellY
parameter, ensuring accurate data processing and naming.