"Error 21: Is a directory" when running a concatenate script
<p>I wrote a program to concatenate some csv files vertically. Here is the program.</p>

<pre><code>import os
import glob
import pandas

def concatenate(indir, outfile, colnames):
    os.chdir(indir)
    fileList=glob.glob('*.csv')
    dfList=[]
    for filename in fileList:
        print(filename)
        df=pandas.read_csv(filename,header=None)
        dfList.append(df)
    concatDf=pandas.concat(dfList,axis=0)
    concatDf.columns=colnames
    y=str(input("What do you want to name your file?"))
    concatDf.csv_path = y
    concatDf.to_csv(outfile,index=None)


def main():
    indir = str(input("What is the directory that you want to concatenate?" ))
    outfile = str(input("What is the directory that you want to export the merged file to?" ))
    string_input = input("What are the column names?: ")
    input_list = string_input.split()
    colnames = [str(x) for x in input_list]
    concatenate(indir, outfile, colnames)
</code></pre>

<p>However, when I test out my program, there is a small error. Here are my inputs.</p>

<pre><code>main()

What is the directory that you want to concatenate?/Users/hem/Desktop/Complete_Pilot_Copy/5555_1/DelayDiscounting

What is the directory that you want to export the merged file to?/Users/hem/Desktop/DelayedDiscountingAnalyzed

What are the column names?: Date    SubjectID   SessionID   ProtocolID  SiteID  TaskID  UserResponse    LogDiscountRate LogDiscountRateStd  QuestionRule    NegativeDiscountFlag    ZeroDiscountFlag    BozoDiscountFlag    gldomain    ProposedValue1  ProposedDelay1  ProposedValue2  ProposedDelay2  ProposedValue3  ProposedDelay3  TrialStartTimeSec   ResponseTimeSec
DDT_5555_1_HUBS071501_BU_062016_135920.csv
DDT_5555_1_HUBS071501_BU_062016_140010.csv
DDT_5555_1_HUBS071501_BU_062016_140051.csv
DelayedDiscounting_5555_1.csv

What do you want to name your file?5555_1DelayDiscounting
Traceback (most recent call last):

  File "&lt;ipython-input-2-58ca95c5b364&gt;", line 1, in &lt;module&gt;
    main()

  File "&lt;ipython-input-1-867fad0a7568&gt;", line 26, in main
    concatenate(indir, outfile, colnames)

  File "&lt;ipython-input-1-867fad0a7568&gt;", line 17, in concatenate
    concatDf.to_csv(outfile,index=None)

  File "/Users/hem/anaconda/lib/python3.5/site-packages/pandas/core/frame.py", line 1344, in to_csv
    formatter.save()

  File "/Users/hem/anaconda/lib/python3.5/site-packages/pandas/formats/format.py", line 1526, in save
    compression=self.compression)

  File "/Users/hem/anaconda/lib/python3.5/site-packages/pandas/io/common.py", line 424, in _get_handle
    f = open(path, mode, errors='replace')

IsADirectoryError: [Errno 21] Is a directory: '/Users/hem/Desktop/DelayedDiscountingAnalyzed'
</code></pre>

<p>How would I fix this? I think it may be the way I entered the directory? Thanks</p>