Hi guys,
I’m trying to override data in a csv file that is stored locally (that is, in the root folder).
the script below works fine in a Colab but not in Streamlit.
Here’s a screenshot of my csv file where I’m looking to override the number n (default value is 1) by n+1 with each run.
Here’s the code I’ve tried:
import streamlit as st
import csv
r = csv.reader(open("test.csv")) # Here your csv file
lines = list(r)
lines
writer = csv.writer(open("test.csv", "w"))
lines[1][1] = int(lines[1][1]) + 1
writer.writerows(lines)
Each time I launch the script, all the data in the csv is erased.
Not sure (yet! :)) what I’m doing wrong
Thanks
Charly