File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
tools/src/main/java/com/datastax/astra/tool Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change 6
6
import com .datastax .astra .client .model .DataAPIKeywords ;
7
7
import com .datastax .astra .client .model .Document ;
8
8
import com .datastax .astra .tool .csv .CsvLoader ;
9
- import com .datastax .astra .tool .csv .CsvLoaderSettings ;
10
9
import com .datastax .astra .tool .csv .CsvRowMapper ;
11
10
import lombok .extern .slf4j .Slf4j ;
12
11
13
12
/**
14
- * Sample Code to load a CSV file into Astra using the DataStax Java Driver
13
+ * Load a CSV to Astra
15
14
*/
16
15
@ Slf4j
17
16
public class CsvLoaderListing {
18
17
19
-
20
18
public static void main (String [] args ) throws Exception {
21
19
// Get an empty Collection
22
20
DataAPIClient client = new DataAPIClient ("<replace_me>" );
@@ -29,8 +27,7 @@ public static void main(String[] args) throws Exception {
29
27
CsvLoader .load (csvFilename , collection , new CsvRowMapper () {
30
28
@ Override
31
29
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
34
31
return doc ;
35
32
}
36
33
});
You can’t perform that action at this time.
0 commit comments