If I understand correctly, you are looping reading multiple files, and want to put the results all into one large table. And that you have a column which will at least sometimes contain text.
The times that it complains about nan: is it possible those are times that the entire column for that variable is empty? The automatic detection will call empty columns as double, not char.
If this is the problem, then there are two potential ways to proceed:
- detectImportOptions each time and setvartype() to force it to text; or
- detectImportOptions only once at the beginning (forcing to text would not hurt), and then use those import options for all remaining files