You can find detailed information at: Export Features to a CSV File using C#
Last active
November 10, 2021 13:13
-
-
Save aspose-com-gists/afa4cdd274f018b334b9dcd202c7a578 to your computer and use it in GitHub Desktop.
Export Features to a CSV File using C#
This file contains 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
var options = new CsvOptions() | |
{ | |
ColumnWkt = "geom_data", | |
Delimiter = ';' | |
}; | |
// Create a new CSV layer | |
using (var layer = Drivers.Csv.CreateLayer(dataDir + "csv_out.csv", options)) | |
{ | |
// Add attributes | |
layer.Attributes.Add(new FeatureAttribute("string_data", AttributeDataType.String)); | |
layer.Attributes.Add(new FeatureAttribute("int_data", AttributeDataType.Integer)); | |
layer.Attributes.Add(new FeatureAttribute("bool_data", AttributeDataType.Boolean)); | |
layer.Attributes.Add(new FeatureAttribute("float_data", AttributeDataType.Double)); | |
Feature feature = layer.ConstructFeature(); | |
feature.SetValue("string_data", "string value"); | |
feature.SetValue("int_data", 10); | |
feature.SetValue("bool_data", true); | |
feature.SetValue("float_data", 3.14); | |
feature.Geometry = new LineString(new[] { new Point(0, 0), new Point(1, 1) }); | |
// Add Feature | |
layer.Add(feature); | |
Feature feature2 = layer.ConstructFeature(); | |
feature2.SetValue("string_data", "string value2"); | |
feature2.SetValue("int_data", 100); | |
feature2.SetValue("bool_data", false); | |
feature2.SetValue("float_data", 3.1415); | |
feature2.Geometry = Geometry.Null; | |
// Add feature | |
layer.Add(feature2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment