I had been running a program where the simulations report out some data in a csv file. It worked fine. But now, suddenly, it has stopped working giving and error message that it cannot make the csv file. When I remove the csv generate command, the simulation runs normally. What could have happened, and is there a workaround? THANK YOU!
THIS DOES NOT RUN:
PVNspike_data = PVN_spktimes.get_states([‘t’,‘i’],units=False,format=‘pandas’)
PVNspike_data.to_csv(‘PVNspikedata.csv’, index=False)
THIS DOES RUN:
PVNspike_data = PVN_spktimes.get_states([‘t’,‘i’],units=False,format=‘pandas’)
#PVNspike_data.to_csv(‘PVNspikedata.csv’, index=False)
What you have aready tried
Expected output (if relevant)
Actual output (if relevant)
Full traceback of error (if relevant)
PermissionError Traceback (most recent call last)
Cell In[12], line 60
41 #PYR1.Ipulse=80 * pA
42 #PYR2.Ipulse=20 * pA
43 #net.run(2ms)
(…)
54 #PYR2.Ipulse=0 * pA
55 #net.run(1000ms)
59 PVNspike_data = PVN_spktimes.get_states([‘t’,‘i’],units=False,format=‘pandas’)
—> 60 PVNspike_data.to_csv(‘PVNspikedata.csv’, index=False)
61 PYRspike_data = PYR_spktimes.get_states([‘t’,‘i’],units=False,format=‘pandas’)
62 PYRspike_data.to_csv(‘PYRspikedata.csv’, index=False)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\util_decorators.py:333, in deprecate_nonkeyword_arguments..decorate..wrapper(*args, **kwargs)
327 if len(args) > num_allow_args:
328 warnings.warn(
329 msg.format(arguments=_format_argument_list(allow_args)),
330 FutureWarning,
331 stacklevel=find_stack_level(),
332 )
→ 333 return func(*args, **kwargs)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\generic.py:3967, in NDFrame.to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, lineterminator, chunksize, date_format, doublequote, escapechar, decimal, errors, storage_options)
3956 df = self if isinstance(self, ABCDataFrame) else self.to_frame()
3958 formatter = DataFrameFormatter(
3959 frame=df,
3960 header=header,
(…)
3964 decimal=decimal,
3965 )
→ 3967 return DataFrameRenderer(formatter).to_csv(
3968 path_or_buf,
3969 lineterminator=lineterminator,
3970 sep=sep,
3971 encoding=encoding,
3972 errors=errors,
3973 compression=compression,
3974 quoting=quoting,
3975 columns=columns,
3976 index_label=index_label,
3977 mode=mode,
3978 chunksize=chunksize,
3979 quotechar=quotechar,
3980 date_format=date_format,
3981 doublequote=doublequote,
3982 escapechar=escapechar,
3983 storage_options=storage_options,
3984 )
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\formats\format.py:1014, in DataFrameRenderer.to_csv(self, path_or_buf, encoding, sep, columns, index_label, mode, compression, quoting, quotechar, lineterminator, chunksize, date_format, doublequote, escapechar, errors, storage_options)
993 created_buffer = False
995 csv_formatter = CSVFormatter(
996 path_or_buf=path_or_buf,
997 lineterminator=lineterminator,
(…)
1012 formatter=self.fmt,
1013 )
→ 1014 csv_formatter.save()
1016 if created_buffer:
1017 assert isinstance(path_or_buf, StringIO)
File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\io\formats\csvs.py:251, in CSVFormatter.save(self)
247 “”"
248 Create the writer & save.
249 “”"
250 # apply compression and byte/text conversion
→ 251 with get_handle(
252 self.filepath_or_buffer,
253 self.mode,
254 encoding=self.encoding,
255 errors=self.errors,
256 compression=self.compression,
257 storage_options=self.storage_options,
258 ) as handles:
259 # Note: self.encoding is irrelevant here
260 self.writer = csvlib.writer(
261 handles.handle,
262 lineterminator=self.lineterminator,
(…)
267 quotechar=self.quotechar,
268 )
270 self._save()