Combine csv files python

Combine multiple csv files in python

Vasav

1 minute read

import os
import glob
import pandas as pd

path = os.getcwd()
extension = 'csv'

csv_files = glob.glob('*.{}'.format(extension))

df_list = []
for file in csv_files:
    df = pd.read_csv(file)
    df_list.append(df)

pd.concat(df_list).to_csv("combined_file.csv", index=False)

Note: In order to perform the same with excel, change the value of extension and use read_excel method instead read_csv.

Create a comma separated string from text in VS Code

VS Code Way of Adding quote and comma in multiline string

Vasav

1 minute read

There are cases when you are copying a column data from excel or other tool in a text editor and you want to format it to be used in SQL in clause or any other usecase. In this article, I am providing a way to do it in VS code.

Working with Data and Time in python

Python data and time notes

Vasav

1 minute read

I had some issue reading a csv directly on the databricks community edition. So after going through some articles, I finally found the workaround. Databricks has disabled to use csv directly for pandas as you may encounter FileNotFoundError: [Errno 2] No such file or directory:.