Linked Questions

Popular Questions

I'm trying to read a CSV file into Prolog knowledge base. Below is the code:

:- use_module(library(csv)).

:- my_csv_read('../UserWeightings/userWeighting_dummy_25Oct2018.csv').


My CSV file only has two columns. Column 1 are URIs, and Column 2 are numbers (represent the weighting for that URI). The file looks like this:

'http://test/weightings#Red', 0.5
'http://test/weightings#Yellow', 0.3
'http://test/weightings#Green', 0.8
'http://test/weightings#Black', 1.2
'http://test/weightings#White', 2

When I run the code, it gives the following error:

ERROR: m:/{file path and line number}
        Domain error: `row_arity(2)' expected, found `1'
Warning: m:/{path and line number}
        Goal (directive) failed: user:my_csv_read('../UserWeightings/userWeighting_dummy_25Oct2018.csv')

Does anyone have an idea why it only reads one column? Thanks a lot!

Related Questions