Hi Ben,

As file:list only returns relative file paths, you will have to prepend the root path later on:

  let $root := "/home/bengbers/DataScience/RBaseX/Examples/Parse/"
  for $file in file:list($root, false(), "*.csv")
  return db:add("CSV_test", $root || $file, "", map {
    'parser': 'csv',
    'csvparser': map { 'header': 'yes', 'separator': ';' }
  })

Another alternative is to use the file:children function:

  let $root := "/home/bengbers/DataScience/RBaseX/Examples/Parse/"
  for $path in file:children($root)[ends-with(., ".csv")]
  return db:add("CSV_test", $path, "", map { ... })

Cheers,
Christian


On Thu, May 31, 2018 at 4:21 PM, Ben Engbers <Ben.Engbers@be-logical.nl> wrote:
Hi,
My goals is to use my R clientdriver to insert csv-files into a new
databases. But before that, I'm experimenting with the GUI.

>From the documentation for the CSV-parser, I have taken this code:

​​
for $file in
file:list("/home/bengbers/DataScience/RBaseX/Examples/Parse", false(),
"*.csv")
return db:add("CSV_test", $file, "", map {
  'parser': 'csv',
  'csvparser': map { 'header': 'yes', 'separator': ';' }
})

BaseX returns: 
Error:
Stopped at /home/bengbers/DataScience/Eindopdracht/Data/file, 2/14:
[FODC0002] Resource 'Test_Parse.csv' does not exist.

I didn't enter this path. It was used yesterday when browsing to the
datafiles that were inserted into another test-database.

let $file :=
file:list("/home/bengbers/DataScience/RBaseX/Examples/Parse", false(),
"*.csv")
return $file

BaseX returns:
Test_Parse.csv
Test_Parse (exemplaar).csv

If I create a new database, it neatly adds the two csv-files.

My questions are:
- which query I have to use to insert csv-files?
- obviously, BasexGUI uses the wrong path. How should I adjust this path?

Cheers,
Ben