1

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

0

1 Answer 1

1

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.

read_csv:

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.