Hi to everyone, I would save data from multiple files in one using pandas.
below my script # Read results GCMG LAMMPS import pandas as pd import os import glob path = r"C:\Users\Documenti\Pyton\plot\results_CH4_180K\METHANE_180K_LJ_2.5-35.0_bar" os.chdir(path) results = pd.DataFrame() for counter, current_file in enumerate(glob.glob("results_*.log")): gcmcdatadf = pd.read_csv(current_file, header=2, sep=" ", usecols=[1, 2, 3]) print(gcmcdatadf) results = pd.concat([results, gcmcdatadf]) #results.to_csv('resuls_tot.log', header=None, sep=" ") In console I obtain Empty DataFrame Columns: [182.244, 10, 0.796176] Index: [] Empty DataFrame Columns: [181.126, 12.5, 0.995821] Index: [] Empty DataFrame Columns: [180.419, 15, 1.21188] Index: [] Empty DataFrame Columns: [179.8, 17.5, 1.43485] Index: [] Empty DataFrame Columns: [198.308, 2.5, 0.255925] Index: [] Empty DataFrame Columns: [179.68, 20, 1.65276] Index: [] Empty DataFrame Columns: [179.629, 22.5, 1.91916] Index: [] Empty DataFrame Columns: [179.838, 25, 2.20493] Index: [] Empty DataFrame Columns: [179.73, 27.5, 2.5408] Index: [] Empty DataFrame Columns: [179.645, 30, 2.98309] Index: [] Empty DataFrame Columns: [179.799, 32.5, 3.65617] Index: [] Empty DataFrame Columns: [180.184, 35, 22.3041] Index: [] Empty DataFrame Columns: [187.835, 5, 0.427784] Index: [] Empty DataFrame Columns: [183.896, 7.5, 0.606451] Index: [] #results.to_csv('resuls_tot.log', name=(T [K],)) How could I eliminate 'index:[]', an print results in one file as #T Pres Density 198.308, 2.5, 0.255925 . . . 180.184, 35, 22.3041 regards A. -- https://mail.python.org/mailman/listinfo/python-list