-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix Load Data from CSV File for Value Map widget #60786
base: master
Are you sure you want to change the base?
Fix Load Data from CSV File for Value Map widget #60786
Conversation
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
1857f92
to
7b2415c
Compare
@@ -402,11 +404,11 @@ void QgsValueMapConfigDlg::loadMapFromCSV( const QString &filePath ) | |||
ceils << match.capturedTexts().last().trimmed().replace( QLatin1String( "\"\"" ), QLatin1String( "\"" ) ); | |||
} | |||
|
|||
if ( ceils.size() != 2 ) | |||
if ( ceils.size() == 0 ) |
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.
@agiudiceandrea
Since the cells.size() > 2
is gone, just wanted to ask you if that's on purpose or if it's still safe.
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.
Thanks for the review!
If my logic isn't faulty, the QStringList ceils
is populated in a previous while ( matches.hasNext() && ceils.size() < 2 )
loop, so it cannot have a size greater than 2: its size can only be either 0 or 1 or 2. If its size is 0, then outside loop will continue
, if it's 1 then key = ceils[0]
and val = QString( "" )
, if it's 2 then key = ceils[0]
and val = ceils[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.
I missed that part, thanks for the explanation!
Description
set UTF-8 codec when reading the CSV file
correctly handle CSV file with a single column without a trailing comma, like
while currently only a CSV like the following one is allowed
Fixes #60765.