python - How to take a data from .dat files without empty columns -
i'm new in pandas , python. have problem don't understand, have set of .dat files, collect them in 1 .csv file.
path =r'/users/desktop/03/17' filenames = glob.glob(path + "/*dat") dfs = [] filename in filenames: dfs.append(pd.read_csv(filename)) data_day = pd.concat(dfs,ignore_index=true) data_day.head() data_day.to_csv('/users/desktop/11.csv',index=false) data2 = pd.read_csv('/users/desktop/11.csv', sep=' ') data1 = data2.dropna(axis=1) data1
it works type of .dat files wich contain 21 columns. 21 columns doesn't work type of files contain 27 columns. 27 columns instead of 27 columns makes files 18 columns. mistake?
the separator in linked files isn't single space, pd.read_csv(..., sep=' ')
failing. seek pd.read_csv(..., delim_whitespace=true)
utilize amount of whitespace separator. should equivalent pd.read_csv(..., sep='\s+')
, faster.
python csv pandas
No comments:
Post a Comment