'Append a row from newly added csv file to the old one in python
I am trying to write a script which will be taking a particular column from a newly added to the folder csv file, and adding it as a row to an old csv file. So, the program should be executing this script whenever a new csv file is added to the folder resulting in one big csv file with many rows.
I have a program which appends csv files into one like this:
path = r'/Users/.../Desktop/files' # use your path
all_files = glob.glob(path + "/*.csv")
li = []
for filename in all_files:
df = pd.read_csv(filename, index_col=None, header=0)
li.append(df)
frame = pd.concat(li, axis=0, ignore_index=True)
frame.to_csv(r'/Users/.../Desktop/files/New.csv', index = False)
But it doesn't really do the full job, as what I want is this row from the newly added file (without a header):
to be appended into this type of file:
It is supposed to be happening whenever the new csv file is dropped to the folder, so maybe time.sleep() function should be used.
I really hope you can help.. I got totally lost when I tried to write the whole script.. :(
P.S. Sorry for the wordiness :/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


