0

I am trying to plug in many .txt files into ArcMap using the below code:

myList=arcpy.GetParameterAsText(0)
print myList



with open('C://folder//myList.txt', 'w') as outfile:
    for fname in windList:
        with open(fname) as infile:
            for line in infile:
                outfile.write(line)

All this does is take multiple text files and essentially merge the two together.

This results in an error shown here:

with open(fname) as infile:
IOError: [Errno 2] No such file or directory: u'C'

Any ideas?

Thanks for any help you can offer

Will B
  • 387
  • 3
  • 6
  • 14
  • Does the `C://folder` folder exist? – Aaron Apr 29 '15 at 03:31
  • Seems that your text file contains some unicode characters. [This](http://stackoverflow.com/a/1207479/2089675) might be of some help – smac89 Apr 29 '15 at 03:35
  • @Aaron I altered the path so it was easier to read. I have the correct path in my actual code though, I triple checked that. – Will B Apr 29 '15 at 03:37
  • 1
    Well which file is it trying to open? Print `fname` before opening. But I suspect your mistake is that `windList` is a string. What is `windList`? – Stefan Pochmann Apr 29 '15 at 04:00
  • @stefanPochmann In ArcMap, I added a script which had a parameter that takes multiple text files. I thought this would create it as a list. – Will B Apr 29 '15 at 04:03
  • @Will B It won't create it as a list, it creates it as a string, with each input separated by a semicolon. You will have to do call the split function to create the list. – papadoo May 15 '15 at 18:28

0 Answers0