Nisarg Pandya
Nisarg Pandya

Reputation: 1

How to insert data from numbers of rows read from csv into a rdf file using jena in Java?

try {

        br = new BufferedReader(new FileReader(csvFile));
        final Resource FlightOperations = model.createResource(NS+"FlightOperations");

        int i=0;
        while ((line = br.readLine()) != null) {
            //  j++;

            String[] flightOperation = line.split(cvsSplitBy);

            model.addLiteral (FlightOperations, rowID, i);
            model.addLiteral (FlightOperations, DataExtractDate, ResourceFactory.createTypedLiteral(flightOperation[0], XSDDatatype.XSDdate));
            model.addLiteral (FlightOperations, ReportPeriod, ResourceFactory.createTypedLiteral(flightOperation[1], XSDDatatype.XSDdate));
            model.addLiteral (FlightOperations, FlightType, ResourceFactory.createTypedLiteral(flightOperation[2], XSDDatatype.XSDstring));
            model.addLiteral (FlightOperations, arrival_departure, ResourceFactory.createTypedLiteral(flightOperation[3], XSDDatatype.XSDstring));
            model.addLiteral (FlightOperations, domestic_international, ResourceFactory.createTypedLiteral(flightOperation[4], XSDDatatype.XSDstring));
            model.addLiteral (FlightOperations, flightOpsCount, ResourceFactory.createTypedLiteral(flightOperation[5], XSDDatatype.XSDint));

            i++;
        }
    }
    catch (FileNotFoundException e) {
        e.printStackTrace();
    }

I am not able to print the the values in the correct order that are in the ccsv file. I want to build rdf with 1369 rows of csv.enter image description here

Upvotes: 0

Views: 50

Answers (1)

AndyS
AndyS

Reputation: 16700

An RDF graph does not preserve order.

If you are simply printing the RDF, it does not matter.

If you are querying the RDF, sort by the recorded row number rowID.

Upvotes: 0

Related Questions