csv2rdf
A commandline tool for semi-automatically converting CSV to RDF.
See also https://github.com/RDFLib/pyTARQL in the RDFlib family of tools
try: csv2rdf --help
Classes:
-
CSV2RDF–
HELP
module-attribute
HELP = '\ncsv2rdf.py -b <instance-base> -p <property-base> [-D <default>] [-c <classname>] [-i <identity column(s)>] [-l <label columns>] [-s <N>] [-o <output>] [-f configfile] [--col<N> <colspec>] [--prop<N> <property>] <[-d <delim>] [-C] [files...]"\n\nReads csv files from stdin or given files\nif -d is given, use this delimiter\nif -s is given, skips N lines at the start\nCreates a URI from the columns given to -i, or automatically by numbering if\nnone is given\nOutputs RDFS labels from the columns given to -l\nif -c is given adds a type triple with the given classname\nif -C is given, the class is defined as rdfs:Class\nOutputs one RDF triple per column in each row.\nOutput is in n3 format.\nOutput is stdout, unless -o is specified\n\nLong options also supported: --base, --propbase, --ident, --class, --label, --out, --defineclass\n\nLong options --col0, --col1, ...\ncan be used to specify conversion for columns.\nConversions can be:\n ignore, float(), int(), split(sep, [more]), uri(base, [class]), date(format)\n\nLong options --prop0, --prop1, ...\ncan be used to use specific properties, rather than ones auto-generated\nfrom the headers\n\n-D sets the default conversion for columns not listed\n\n-f says to read config from a .ini/config file - the file must contain one\nsection called csv2rdf, with keys like the long options, i.e.:\n\n[csv2rdf]\nout=output.n3\nbase=http://example.org/\ncol0=split(";")\ncol1=split(";", uri("http://example.org/things/",\n "http://xmlns.com/foaf/0.1/Person"))\ncol2=float()\ncol3=int()\ncol4=date("%Y-%b-%d %H:%M:%S")\n\n'
config_functions
module-attribute
config_functions = {'ignore': _config_ignore, 'uri': _config_uri, 'literal': _config_literal, 'float': _config_float, 'int': _config_int, 'date': _config_date, 'split': _config_split, 'replace': _config_replace, 'bool': _config_bool}
CSV2RDF
Methods:
Attributes:
-
BASE– -
CLASS– -
COLUMNS– -
DEFAULT– -
DEFINECLASS– -
DELIM– -
IDENT(Union[Tuple[str, ...], str]) – -
LABEL– -
OUT– -
PROPBASE– -
PROPS– -
SKIP– -
triples–
Source code in rdflib/tools/csv2rdf.py
convert
Source code in rdflib/tools/csv2rdf.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | |
NodeBool
NodeDate
Bases: NodeLiteral
Methods:
NodeFloat
NodeInt
NodeLiteral
NodeMaker
NodeSplit
NodeUri
column
csv_reader
index
main
Source code in rdflib/tools/csv2rdf.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
prefixuri
prefixuri(x, prefix, class_: Optional[URIRef] = None)
toProperty
CamelCase + lowercase initial a string
FIRST_NM => firstNm
firstNm => firstNm