I have 2 files which need to populate the same csv file
To give context, currently, I have this code that prints a CSV in the desired way code-1.py
Current Existing added:
array_all = {'Hand': alldata, 'Pose': face_position}
array_all = {k: pd.Series(v) for k, v in array_all.items()}
df = pd.DataFrame(array_all)
df.to_csv('test.csv',
mode='w',
header=True,
index=False)
| Hand | Pose |
|---|---|
| No | Seating Back |
| No | Seating Back |
and now I have code-2.py
Column to add:
df = pd.DataFrame(results)
df.to_csv('test.csv',
mode='a',
header=True,
index=False)
what I want this to do is add a column to the right Desired Output:
| Hand | Pose | Eye |
|---|---|---|
| No | Seating Back | Left |
| No | Seating Back | Right |
However, currently I am getting this,
Actual Output:
| Hand | Pose |
|---|---|
| No | Seating Back |
| No | Seating Back |
| 0 | |
| Right | |
| Left |
Basically, it is appending to the first column of the CSV Also, it can be assumed that code-2.py will be run immediately following code-1.py
Appreciate any ideas about this, Thank you!