Skip to content

Commit 5e65f34

Browse files
committed
update sample
1 parent b4520e9 commit 5e65f34

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

tools/src/main/java/com/datastax/astra/tool/CsvLoaderListing.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@
66
import com.datastax.astra.client.model.DataAPIKeywords;
77
import com.datastax.astra.client.model.Document;
88
import com.datastax.astra.tool.csv.CsvLoader;
9-
import com.datastax.astra.tool.csv.CsvLoaderSettings;
109
import com.datastax.astra.tool.csv.CsvRowMapper;
1110
import lombok.extern.slf4j.Slf4j;
1211

1312
/**
14-
* Sample Code to load a CSV file into Astra using the DataStax Java Driver
13+
* Load a CSV to Astra
1514
*/
1615
@Slf4j
1716
public class CsvLoaderListing {
1817

19-
2018
public static void main(String[] args) throws Exception {
2119
// Get an empty Collection
2220
DataAPIClient client = new DataAPIClient("<replace_me>");
@@ -29,8 +27,7 @@ public static void main(String[] args) throws Exception {
2927
CsvLoader.load(csvFilename, collection, new CsvRowMapper() {
3028
@Override
3129
public Document map(Document doc) {
32-
doc.put(DataAPIKeywords.ID.getKeyword(), doc.get("id"));
33-
doc.remove("id");
30+
doc.append("_id", doc.get("id")).remove("id"); // rename field id to _id
3431
return doc;
3532
}
3633
});

0 commit comments

Comments
 (0)