Fix Load Data from CSV File for Value Map widget #63283
Open
+74
−3
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.
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.
(proposed again after #61568 and #62591 were closed by the stale bot)
P.S. @nyalldawson, it seems to me using
QString( "" )
(instead ofQString()
as you proposed) is needed: it is due to the fact thatQgsValueMapConfigDlg::config()
behaves differently if theQTableWidgetItem.text()
of the value is aQString()
QGIS/src/gui/editorwidgets/qgsvaluemapconfigdlg.cpp
Lines 72 to 79 in 69a79ed
When a row like
1,
is loaded, the regex has 2 matches:1
for the key and an empty (not null) QString for the value. The output of QgsValueMapConfigDlg::config() will contain a map with the key1
and an empty (not null) QString as the value.When a row like
1
is loaded, the regex has 1 match:1
for the key.If we use a null QString for the value, then the output of
QgsValueMapConfigDlg::config()
will contain a map with the key1
and also1
as the value, instead of a map with the key1
and an empty QString as the value.We need to use an empty (not null) QString as the value, in order to make
QgsValueMapConfigDlg::config()
output the same map like when a row like1,
is loaded.