Python - Pandas Combining parts of multiple files
<p>Have a list of 200 or so files in a folder. Each has the same amount of columns but there can be some variation in the naming. For instance, i can have Global ID or Global id or Global Id. Is there a way to control for case in pandas column names so that it doesnt matter what it equals? Currently it will get through the first 15 or so files out of 200 and will error because it doesnt find Global ID.</p>

<p>Caveat that im a beginner and still learning.</p>

<pre><code>import pandas as pd
import glob

with open('test99.txt' , 'a') as out:
    list_of_files = glob.glob('M:\AD HOC Docs\Client\Blinded\*')
    for file_name in list_of_files:
        df = pd.read_table(file_name, low_memory=False)
        df['Client'] = file_name.split("_")[2].strip()
        Final = df[['Client','ClientID','Global ID','Internal ID','campaign type','engagement type', 'file_name']]
        Final.to_csv(out,index=False)
</code></pre>

<p>Use <code>header=None, names=[list of column names you want to use]</code> as additional argument to <code>read_table</code>to ignore the header row and to get consistent names.</p>

python pandas