Reputation: 1561
I have a set of csv files that I am trying to concat. I am having issues that the concatenated file does not apply the comma separators to the content. Given below is the code:
##Location where the csv files are located
updatedfiles = glob.glob(LOCAL_PATH2 + "/*.csv")
#Applying comma separator to the concatenated output
df_v1 = [pd.read_csv(fp, sep=',', delim_whitespace=True).assign(FileName=os.path.basename(fp)) for fp in updatedfiles]
Could anyone guide me on this. Thanks
Upvotes: 1
Views: 126
Reputation: 862511
I believe need to remove delim_whitespace=True
, because 2 separators ,
and whitespace. If need both sep='\s+|,'
should working or parameter skipinitialspace=True
it need remove trailing whitespaces.
delim_whitespace : boolean, default False
Specifies whether or not whitespace (e.g. ' ' or '\t') will be used as the sep. Equivalent to setting sep='\s+'. If this option is set to True, nothing should be passed in for the delimiter parameter.
Upvotes: 1