use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldImportWithHeadersBeingInSeparateFiles.
@Test
void shouldImportWithHeadersBeingInSeparateFiles() throws Exception {
// GIVEN
List<String> nodeIds = nodeIds();
Configuration config = Configuration.TABS;
Path dbConfig = prepareDefaultConfigFile();
// WHEN
runImport("--additional-config", dbConfig.toAbsolutePath().toString(), "--delimiter", "TAB", "--array-delimiter", String.valueOf(config.arrayDelimiter()), "--nodes", nodeHeader(config).toAbsolutePath().toString() + "," + nodeData(false, config, nodeIds, TRUE).toAbsolutePath().toString(), "--relationships", relationshipHeader(config).toAbsolutePath().toString() + "," + relationshipData(false, config, nodeIds, TRUE, true).toAbsolutePath().toString());
// THEN
verifyData();
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldBeAbleToMixSpecifiedAndUnspecifiedGroups.
@Test
void shouldBeAbleToMixSpecifiedAndUnspecifiedGroups() throws Exception {
// GIVEN
List<String> groupOneNodeIds = asList("1", "2", "3");
List<String> groupTwoNodeIds = asList("4", "5", "2");
Configuration config = Configuration.COMMAS;
Path dbConfig = prepareDefaultConfigFile();
// WHEN
runImport("--additional-config", dbConfig.toAbsolutePath().toString(), "--nodes", nodeHeader(config, "MyGroup").toAbsolutePath().toString() + "," + nodeData(false, config, groupOneNodeIds, TRUE).toAbsolutePath().toString(), "--nodes", nodeHeader(config).toAbsolutePath().toString() + "," + nodeData(false, config, groupTwoNodeIds, TRUE).toAbsolutePath().toString());
// THEN
verifyData(6, 0, Validators.emptyValidator(), Validators.emptyValidator());
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class ImportCommandTest method shouldTreatRelationshipWithMissingStartOrEndIdOrTypeAsBadRelationship.
@Test
void shouldTreatRelationshipWithMissingStartOrEndIdOrTypeAsBadRelationship() throws Exception {
// GIVEN
List<String> nodeIds = asList("a", "b", "c");
Configuration config = Configuration.COMMAS;
Path nodeData = nodeData(true, config, nodeIds, TRUE);
List<RelationshipDataLine> relationships = Arrays.asList(relationship("a", null, "TYPE"), relationship(null, "b", "TYPE"), relationship("a", "b", null));
Path relationshipData = relationshipData(true, config, relationships.iterator(), TRUE, true);
Path bad = badFile();
// WHEN importing data where some relationships refer to missing nodes
runImport("--nodes", nodeData.toAbsolutePath().toString(), "--report-file", bad.toAbsolutePath().toString(), "--skip-bad-relationships", "true", "--relationships", relationshipData.toAbsolutePath().toString());
String badContents = Files.readString(bad, Charset.defaultCharset());
assertEquals(3, occurrencesOf(badContents, "is missing data"), badContents);
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class QuickImport method parseNodeHeader.
private static Header parseNodeHeader(Args args, IdType idType, Extractors extractors, Groups groups) {
String definition = args.get("node-header", null);
if (definition == null) {
return DataGeneratorInput.bareboneNodeHeader(idType, extractors);
}
Configuration config = Configuration.COMMAS;
return DataFactories.defaultFormatNodeFileHeader().create(seeker(definition, config), config, idType, groups);
}
use of org.neo4j.csv.reader.Configuration in project neo4j by neo4j.
the class CsvInputTest method shouldTreatEmptyQuotedStringsAsNullIfConfiguredTo.
@Test
public void shouldTreatEmptyQuotedStringsAsNullIfConfiguredTo() throws Exception {
// GIVEN
Iterable<DataFactory> data = datas(CsvInputTest.data(":ID,one,two,three\n" + "1,\"\",,value"));
Configuration config = config().toBuilder().withEmptyQuotedStringsAsNull(true).build();
Input input = new CsvInput(data, defaultFormatNodeFileHeader(), datas(), defaultFormatRelationshipFileHeader(), IdType.INTEGER, config, NO_MONITOR, INSTANCE);
// WHEN
try (InputIterator nodes = input.nodes(EMPTY).iterator()) {
// THEN
assertNextNode(nodes, 1L, properties("three", "value"), labels());
assertFalse(readNext(nodes));
}
}
Aggregations