Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Haven: The file's timestamp string is invalid #683

Closed
AlejandroDGR opened this issue May 26, 2022 · 6 comments · Fixed by #713
Closed

Haven: The file's timestamp string is invalid #683

AlejandroDGR opened this issue May 26, 2022 · 6 comments · Fixed by #713
Labels

Comments

@AlejandroDGR
Copy link

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.

@gorcha gorcha added reprex needs a minimal reproducible example readstat labels May 30, 2022
@gorcha
Copy link
Member

gorcha commented May 30, 2022

HI @AlejandroDGR, thanks for the bug report.

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

@AlejandroDGR
Copy link
Author

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).

@gorcha gorcha removed the reprex needs a minimal reproducible example label May 31, 2022
@gorcha
Copy link
Member

gorcha commented May 31, 2022

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?

@JulianEGerez
Copy link

JulianEGerez commented Oct 21, 2022

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

@gorcha
Copy link
Member

gorcha commented Oct 23, 2022

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 added a commit that referenced this issue Feb 21, 2023
Maintains iconv hack from c1f9f19 and solaris hack from 4a878a1.

* Fix various SAS catalog file reading bugs (fix #529, fix #653, fix #680, fix #696, fix #705).
* Increase maximum SAS page file size to 16MB (fix #697).
* Ignore invalid SAV timestamp strings (fix #683).
* Fix compiler warnings (fix #707).
@gorcha gorcha closed this as completed in 196e8eb Feb 22, 2023
@philmikejones
Copy link

Following this fix I don't get errors for .sav files anymore (at least that I've noticed). I have, however, run into a .por file not working. The workaround was to ask a friend with SPSS installed to open the .por, save as a .sav, and to open this file (presumably ignoring the invalid timestamp string).

@gorcha is this something that could be updated to ignore .por timestamps, too? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants