DistanceDevelopment / readdst

Convert Distance for Windows projects into R code/data
GNU General Public License v3.0
1 stars 2 forks source link

Is it really impossible to have spaces in project path? #19

Closed erex closed 8 years ago

erex commented 8 years ago

I know you spent a chunk of Friday fighting with spaces in path names. But it inhibits the utility of readdst that it can only work with directories and files without spaces. By default DisWin projects are stored in a folder called "My Distance Projects" and of the sample files that ship with DisWin, 4 of those file names contain spaces.

Maybe I don't understand the 'proper delimiting' business. My experiment suggests it is not RODBC functions that struggle with spaces

setwd("C:/Users/erexstad/Documents/My Distance Projects/Sample Projects")
library(RODBC)
projectname <- "Line Transect Example"
datafile <- paste(getwd(), "/", projectname, ".dat/DistData.mdb",sep="")
data <- odbcConnectAccess2007(datafile)
obstable <- sqlFetch(data, "Observation")
resultfile <- paste(getwd(), "/", projectname, ".dst", sep="")
result <- odbcConnectAccess2007(resultfile)
analysis.result.stat <- sqlFetch(result, "AnalysisResultsStats")

Do problems arise further downstream after sqlFetch()? If not, can the blockade of 'paths with spaces' be lifted?

dill commented 8 years ago

Paths with spaces in should work, they just must be escaped properly. It's possible this behaviour is to do with mdb.get rather than RODBC.

In any case, my long/path with/spaces should become my\\ long/path\\ with/spaces and work fine.

erex commented 8 years ago

Frustrating:

[1] "C:/Users/eric/readdst-workshop/D70Cluster\\ solutions"
Error in db_get(project_file, "ProjectSettings") : 
  RODBC is unable to open C:/Users/eric/readdst-workshop/D70Cluster\ solutions.dst
  table= ProjectSettings
In addition: Warning messages:
1: In odbcDriverConnect(dsn) :
  [RODBC] ERROR: state HY024, code -1023, message [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
2: In odbcDriverConnect(dsn) :
  [RODBC] ERROR: state 01000, code 1, message [Microsoft][ODBC Microsoft Access Driver]General Warning Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1f94 Thread 0x1a0c DBC 0x13d3c354 Jet'.
3: In odbcDriverConnect(dsn) : ODBC connection failed
Called from: db_get(project_file, "ProjectSettings")
erex commented 8 years ago

The above error is thrown in db_get() because of a malformed path. However if lines 22-24 were replaced with more specific code to get into Access2007 databases

db <- odbcConnectAccess2007(file)

then the line would parse as

db <- odbcConnectAccess2007("C:/Users/eric/readdst-workshop/D70Cluster solutions.dst")

which throws no errors.

dill commented 8 years ago

I had been trying to avoid using the version specific code in the packge as this would require an import of that function, which does not exist on non-Windows platforms.

I'll look at a work-around for this.

dill commented 8 years ago

Will:

odbcDriverConnect("Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:/Users/eric/readdst-workshop/D70Cluster solutions.dst")

work for you?

erex commented 8 years ago

the answer is 'yes' that string works on Win7; however JaNet still has DoS attacks, so I can't get to github to tell you this.

On 07/12/2015 22:17, DL Miller wrote:

Will:

|odbcDriverConnect("Driver={Microsoft Access Driver (.mdb, .accdb)};DBQ=C:/Users/eric/readdst-workshop/D70Cluster solutions.dst") |

work for you?

— Reply to this email directly or view it on GitHub https://github.com/DistanceDevelopment/readdst/issues/19#issuecomment-162684814.

Eric Rexstad 20 West Braes Crescent Crail Fife KY10 3SY

dill commented 8 years ago

Thanks for checking this Eric. Code in readdst has been changed as of fcf5bce. Let me know if that fixes things for you.

On 08/12/2015 04:41, erex wrote:

the answer is 'yes' that string works on Win7; however JaNet still has DoS attacks, so I can't get to github to tell you this.

On 07/12/2015 22:17, DL Miller wrote:

Will:

|odbcDriverConnect("Driver={Microsoft Access Driver (.mdb, .accdb)};DBQ=C:/Users/eric/readdst-workshop/D70Cluster solutions.dst") |

work for you?

— Reply to this email directly or view it on GitHub

https://github.com/DistanceDevelopment/readdst/issues/19#issuecomment-162684814.

Eric Rexstad 20 West Braes Crescent Crail Fife KY10 3SY

— Reply to this email directly or view it on GitHub https://github.com/DistanceDevelopment/readdst/issues/19#issuecomment-162831847.

erex commented 8 years ago

anything to create a diversion from marking. My sense today is that I taught them nothing in the past 12 weeks of my (and their) life.

Project marks awarded today (all on a 40-mark scale): 8, 11, 10, 22, 16, 17

erex commented 8 years ago

Doesn't exactly work, because you still have the gate locked on line 20 of convert_project.R [1] "C:/Users/eric/readdst-workshop/D70Cluster solutions" Error in convert_project(fname) : Project path contains spaces, please escape them properly using "\"

dill commented 8 years ago

Ah, whoops. Try 5a6ec99.

On 08/12/2015 11:45, erex wrote:

Doesn't exactly work, because you still have the gate locked on line 20 of convert_project.R [1] "C:/Users/eric/readdst-workshop/D70Cluster solutions" Error in convert_project(fname) : Project path contains spaces, please escape them properly using "\"

— Reply to this email directly or view it on GitHub https://github.com/DistanceDevelopment/readdst/issues/19#issuecomment-162941375.

erex commented 8 years ago

Mixed reaction...

I think db_get may be contented, but the Cluster solutions project throws up new challenges apparently when trying to make a dataframe out of something:

[1] "C:/Users/eric/readdst-workshop/D70Cluster solutions"
Loading required package: RODBC
Error in data.frame(Region.Label = names(Effort.by.region), CoveredArea = CoveredArea,  : 
  arguments imply differing number of rows: 2, 0
Called from: data.frame(Region.Label = names(Effort.by.region), CoveredArea = CoveredArea, 
    Effort = as.vector(Effort.by.region))
dill commented 8 years ago

Okay, the first issue with spaces is now fixed, I think (63c8747). Let's move this new problem to a new issue in #20.