haven icon indicating copy to clipboard operation
haven copied to clipboard

Haven: The file's timestamp string is invalid

Open AlejandroDGR opened this issue 2 years ago • 3 comments

I try to read SPSS format:

dataframe <- as.data.frame(read_sav("C:/~FilePath/Dataset.sav"))

and get:

Error in df_parse_sav_file(spec, encoding, user_na, cols_skip, n_max, : Failed to parse ~FilePath/Dataset: The file's timestamp string is invalid.

This has been posted in a closed issue (The file's timestamp string is invalid #488) and in a Stackoverflow question [(Difficulty with haven package Reading SPSS data in R)](https://stackoverflow.com/questions/60006760/difficulty-with-haven-package-reading-spss-data-in-r), but I have not found any solution yet.

AlejandroDGR avatar May 26 '22 12:05 AlejandroDGR

HI @AlejandroDGR, thanks for the bug report.

Are you able to share a copy of the file causing the issue so we can investigate?

gorcha avatar May 30 '22 00:05 gorcha

Of course @gorcha!

It happens to me with several files. All of them come from the Spanish National Sociological Centre, like this example

Luckily, they're a minority (the great majority of Spanish National Sociological Centre's files work fine).

AlejandroDGR avatar May 30 '22 10:05 AlejandroDGR

Perfect, thanks!

@evanmiller this is related to #488, but for SPSS files rather than Stata. The fix provided for #488 ignores invalid timestamps rather than throwing an error but only for Stata files, so an invalid timestamp will still throw an error in an SPSS file. I think the SPSS timestamp parsing code just needs to continue on failure like the Stata code?

gorcha avatar May 31 '22 00:05 gorcha

I'm having this issue as well for a file from the same origin as @AlejandroDGR's. I'm wondering if the issue has been resolved as the problem appeared to have been identified and fixed for Stata files. @gorcha

JulianEGerez avatar Oct 21 '22 13:10 JulianEGerez

Hi @JulianEGerez,

We're waiting for PR WizardMac/ReadStat#277 to be merged in the underlying ReadStat library to resolve this. I've followed up with the maintainer over there, hopefully won't be too long.

gorcha avatar Oct 23 '22 03:10 gorcha