QGIS by default saves csv files with values separated by a comma, but I want to save my csv files with semicolons. When I save a vector layer as csv, I can choose if saving with a comma, semicolon, or others, but changing every time such option is tedious. Moreover, some plugins (e.g. 'Point sampling tool') save csv files without giving you the possibility to choose commas or semicolons.

Is there a way to set semicolons as the default in QGIS?


It's hard-coded and you cannot change the default value until developers add an option to change the default value.

This is the related source code of Layer Options: Link

layerOptions.insert( QStringLiteral( "SEPARATOR" ), new QgsVectorFileWriter::SetOption(
                       QObject::tr( "Field separator character." ),
                       << QStringLiteral( "COMMA" )
                       << QStringLiteral( "SEMICOLON" )
                       << QStringLiteral( "TAB" ),
                       QStringLiteral( "COMMA" ) // Default value
                     ) );
  • Thank you. Can I modify this code in some way in the python console?
    – user140119
    Feb 18 '21 at 21:37
  • I don't think so. This is C++ code. You have to build QGIS from scratch. Feb 18 '21 at 21:52
  • You can use QgsVectorFileWriter.writeAsVectorFormat method (in Python concole) to export a layer to CSV by specifying a separator but I don't think it is easier than selecting it manually. Feb 18 '21 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.