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
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
Hi Christian,
The alternative worked so my first question is answered. But the second question still remains.
Why does BaseX-GUI use an old path (/home/bengbers/DataScience/Eindopdracht/Data/file), a path I didn't even enter and does not use the path I entered in the query (/home/bengbers/DataScience/RBaseX/Examples/Parse/)?
Cheers, Ben
Op 01-06-18 om 12:38 schreef Christian Grün:
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
Hi Ben,
This may be the directory where you started the BaseX server from. If you use the client/server architecture, both the client and the server can have different working directories, so you should always specify full paths.
Cheers, Christian
Ben Engbers Ben.Engbers@be-logical.nl schrieb am Fr., 1. Juni 2018, 13:47:
Hi Christian,
The alternative worked so my first question is answered. But the second question still remains.
Why does BaseX-GUI use an old path (/home/bengbers/DataScience/Eindopdracht/Data/file), a path I didn't even enter and does not use the path I entered in the query (/home/bengbers/DataScience/RBaseX/Examples/Parse/)?
Cheers, Ben
Op 01-06-18 om 12:38 schreef Christian Grün:
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
basex-talk@mailman.uni-konstanz.de