You are not logged in. You can browse but not post. Login or Register by clicking 'Login or Register' at the top-right of this page. For more information on Statalist, see the FAQ.
Hi Stata Users. I have multiple text file but without .txt extension. As I have many files I do not want to rename each file by adding .txt. Is there a way I can import to stata without adding the .txt extension?
Yes, you can import the file without a .txt extension using the same syntax as for the files that do have a .txt extension.
Or you can add the txt extension to ALL at once, rather than to EACH one.
Whichever is simpler.
Dear Sergiy. Thanks for the response. However, without extension, by default it considers .cvs and it fails to open. Also, can you tell me the steps to add the txt extension to ALL at once?
If filename is specified without an extension, .csv is assumed for both import delimited and export delimited.(No extention may be specified by "filename." )
Code:
copy https://www.stata.com/examples/auto.csv auto
dir auto
import delimited using "auto." , clear
describe
Hi Bjarte , thanks. yes I know .cvs is assumed if not extension is specified. That is the problem. I know the file is in .txt but it is not specified as such. It simply says file. When I import, it rightly say the file is not in .cvc. When I manually change the file extension to .txt, it works. However, I have too many file to change all of it to .txt. That is why I am asking is there a way I can import a text file without .txt extension to stata without adding the .txt extension manually, en mass ?
Comment