简体   繁体   English

如何使用Java中的jena将从csv读取的行数中的数据插入到rdf文件中?

[英]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. 我无法按照ccsv文件中的正确顺序打印值。 I want to build rdf with 1369 rows of csv. 我想用1369行csv建立rdf。 enter image description here 在此处输入图片说明

An RDF graph does not preserve order. RDF图不保留顺序。

If you are simply printing the RDF, it does not matter. 如果仅打印RDF,则没有关系。

If you are querying the RDF, sort by the recorded row number rowID . 如果要查询RDF,请按记录的行号rowID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM