KentonWhite / ProjectTemplate

A template utility for R projects that provides a skeletal project.
http://projecttemplate.net
GNU General Public License v3.0
623 stars 159 forks source link

Data Directory Automatic .file Files Loading error #251

Closed UTexas80 closed 6 years ago

UTexas80 commented 6 years ago

Report an Issue / Request a Feature

I'm submitting a (Check one with "x") :


Issue Severity Classification -

(Check one with "x") :

Expected Behavior
Steps to Reproduce Behavior

I have attached the tbl.cancel.file for additional documentation. The context of the file is:

path: O:/IT/Scholarships Project/Files/tbl_Cancels extension: csv

Version Information
rsangole commented 6 years ago

@UTexas80 I don't see a tbl.cancel.file attached. Could you check again please?

UTexas80 commented 6 years ago

tbl_BannerCohorts.file.txt

UTexas80 commented 6 years ago

Hi Rahul - Thank you for your prompt response. I apologize for the oversight. I just attached the file and accidentally closed the issue but reopened back open

On Wed, May 2, 2018 at 9:08 AM, Rahul S notifications@github.com wrote:

@UTexas80 https://github.com/UTexas80 I don't see a tbl.cancel.file attached. Could you check again please?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KentonWhite/ProjectTemplate/issues/251#issuecomment-385971634, or mute the thread https://github.com/notifications/unsubscribe-auth/APWzEVc2C_ptmPu4qP1rXSTbhtIroqZ3ks5tua-_gaJpZM4TvadI .

path: O:/IT/Scholarships Project/Files/tbl_BannerCohorts extension: csv

KentonWhite commented 6 years ago

This is from the Google Groups submission and might provide a bit more context:

Hello,

I was wondering if you can please provide some guidance regarding the .file Files loading feature. I am attempting to load data that is not stored in the current project using a .file file.

I specified the path and the extension that the file would have as if it were being loaded by the standard ProjectTemplate auto-loader. The error I received is as follows:

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 1 did not have 3 elements
In addition: Warning message:
In read.table(filename, header = config$data_loading_header) :
  incomplete final line found by readTableHeader on 'data/tbl_Cancels.file.txt'

I have attached the tbl.cancel.file for additional documentation. The context of the file is:

path: O:/IT/Scholarships Project/Files/tbl_Cancels extension: csv tbl_Cancels.file.txt

KentonWhite commented 6 years ago

@UTexas80 My first thought is that the file is called tbl_Cancels.file.txt and so might be read by the txt file reader. Can you change the name to tbl_Cancels.file and see if the error message changes?

UTexas80 commented 6 years ago

Hey Kenton - I have tried that approach but windows still references the file as .txt. In other words, after I remove the .file extension the properties of the file are still a text source file. I am unsure as to how to designate it as a .file File as specified in the Project Template documentation. Do you have a working example of one of these files? Thank you.

rsangole commented 6 years ago

@UTexas80 on a windows machine I think it's possible to remove/rename the extension but windows tries to be "clever" and keeps it in the back end. It's quite annoying. Have you ensured the file extention is truly being changed? There's an option through explorer I believe, or try doing it through the command line.

UTexas80 commented 6 years ago

Yes Rahul, I have absolutely removed the .file extension. Do you have an example of creating it through the command line? I did a google search but came up empty.

Hugovdberg commented 6 years ago

You should not remove the .file part but the .txt part instead. If the the file now is called tbl_Cancels.txt it will indeed be parsed by the txt.reader and not the file.reader. You can use the list.data() command in R to see al your data files and cached variables and an indication which reader is selected for the file.

Hugovdberg commented 6 years ago

If you could paste the output of list.data() in the issue we can more effectively help you troubleshoot your problem.

UTexas80 commented 6 years ago

image input input.xls input FALSE FALSE meta meta.xls meta FALSE FALSE tbl.BannerCohorts tbl_BannerCohorts.txt tbl.BannerCohorts FALSE FALSE tbl.Cancels tbl_Cancels.csv tbl.Cancels FALSE FALSE tbl.scholarshipAwd tbl_scholarshipAwd.csv tbl.scholarshipAwd FALSE FALSE tbl.scholarshipCohorts tbl_scholarshipCohorts.csv tbl.scholarshipCohorts FALSE FALSE tblGaCommitmentFundList.OSFA tblGaCommitmentFundList_OSFA.csv tblGaCommitmentFundList.OSFA FALSE FALSE is_cached cache_only reader input FALSE FALSE xls.reader meta FALSE FALSE xls.reader tbl.BannerCohorts TRUE FALSE wsv.reader tbl.Cancels TRUE FALSE csv.reader tbl.scholarshipAwd TRUE FALSE csv.reader tbl.scholarshipCohorts TRUE FALSE csv.reader tblGaCommitmentFundList.OSFA TRUE FALSE csv.reader

Hugovdberg commented 6 years ago

You can see that the file is called tbl_BannerCohorts.txt, and it will be imported using the wsv.reader (for whitespace separated values). You can actually rename the file from within R by calling file.rename. I guess you should call

file.rename('data/tbl_BannerCohorts.txt', 'data/tbl_BannerCohorts.file')

to fix the issue.

UTexas80 commented 6 years ago

Here is the result after calling the file.rename function:

Loading data set: tbl.BannerCohorts Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'O:/IT/Scholarships Project/Files/tbl_BannerCohorts': No such file or directory Here is my directory contents:

image

and here is my list.data output

list.data function (override.config = NULL) { config <- .load.config(override.config) .list.data(config) }

rsangole commented 6 years ago

@UTexas80 you need to call list.data() to run the function. list.data will only print the function itself.

UTexas80 commented 6 years ago

My apologies...

image

list.data() filename varname is_ignored is_directory tbl.BannerCohorts tbl_BannerCohorts.file tbl.BannerCohorts FALSE FALSE input input.xls input FALSE FALSE meta meta.xls meta FALSE FALSE tbl.Cancels tbl_Cancels.csv tbl.Cancels FALSE FALSE tbl.scholarshipAwd tbl_scholarshipAwd.csv tbl.scholarshipAwd FALSE FALSE tbl.scholarshipCohorts tbl_scholarshipCohorts.csv tbl.scholarshipCohorts FALSE FALSE tblGaCommitmentFundList.OSFA tblGaCommitmentFundList_OSFA.csv tblGaCommitmentFundList.OSFA FALSE FALSE is_cached cache_only reader tbl.BannerCohorts TRUE FALSE file.reader input FALSE FALSE xls.reader meta FALSE FALSE xls.reader tbl.Cancels TRUE FALSE csv.reader tbl.scholarshipAwd TRUE FALSE csv.reader tbl.scholarshipCohorts TRUE FALSE csv.reader tblGaCommitmentFundList.OSFA TRUE FALSE csv.reader

Hugovdberg commented 6 years ago

Ah I guess I see what's going wrong now, so you have the tbl_BannerCohorts.file which points at a file in another location. That file is read correctly but now the path setting inside that file points to a file without the extension:

path: O:/IT/Scholarships Project/Files/tbl_BannerCohorts
extension: csv

If you add the file extension to the path variable (which could differ from the extension in the extension setting) then the file.reader should be able to read the file you try to import.

UTexas80 commented 6 years ago

YES!!!!!

That's so awesome. That did the trick. Thank you very much!