Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • text file without the .txt extension

    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?

    Thanks

  • #2
    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.

    Comment


    • #3
      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?

      Comment


      • #4
        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

        Comment


        • #5
          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


          • #6
            No extention may be specified by "filename."
            ref. code example.

            Comment

            Working...
            X