Read dBase / Paradox data into R?

2019-07-28 19:31发布

I have a hundred or so database files I inherited that I'm currently reading with "Paradox dBase Access Reader", and exporting manually to pipe-delimited text files. I'd LOVE to do this with some kind of access library that would let me read these files directly into R.

The reader tool states that these files are "Paradox 5.0 for Windows", and they have a .db extension on them.

I was hopeful that I could use the foreign package to read them, because it states in the docs for the read.dbf() function:

DBF is the extension used for files written for the ‘XBASE’ family of database languages, covering the dBase, Clipper, FoxPro, and their Windows equivalents Visual dBase, Visual Objects, and Visual FoxPro, plus some older products’

Unfortunately, it fails in the DBFOpen C function, at around line 425:

if( fread( pabyBuf, nHeadLen-32, 1, psDBF->fp ) != 1 )
{
  fclose( psDBF->fp );
  free( pabyBuf );
  free( psDBF );
  return NULL;
}

Anyone have other solutions, or insight into whether read.dbf() is a good or bad match here?

标签: r dbase paradox
2条回答
太酷不给撩
2楼-- · 2019-07-28 19:49

The list does not mention Paradox 5.0 explicitely, Your effort to read it using read.dbf failed. It the files are static, i.e. not changing anymore, I would just create a script to export them once, read them into R, and dump the result using save this way you can just read the data into R using load.

If the data is not too big, this will be a quick process, and allowing you to easily read all the data and extract any subset you like. If it is big, you could invest some time to dump the files into a more modern database, e.g. sqlite (although this is not a full blown database, it is nice and lightweight). I wouldn't invest too much time in gaining direct access from R to these ancient files if it is not strictly necessary...

查看更多
爷、活的狠高调
3楼-- · 2019-07-28 20:06

A search for "paradox db" on rseek.org yields the gnumeric package, which says it can read Paradox files. I don't have any way to test that functionality, but it just might work...

查看更多
登录 后发表回答