0

I'm using IPython 3.4 via Anaconda on Windows 10 (yes, I know). I took a script that I wrote in the same version of IPython in Ubuntu on my virtual machine and tried running it on the Windows side. I've been trying to resolve the issue with "/" used in Linux for file paths as opposed to "\" used in Windows. I tried simply converting all instances of "/" to "\" on the Windows side, but still received the following error:

OSError: [Errno 22] Invalid argument:
C:\\Users\\mike\\Desktop\\S15 NWEA\\Combined_CSVs\\Students_All 2015-08-27 20:12:34.csv'

I'm hoping there's an easy solution for this. Is there?

Here is the whole error output:

OSError Traceback (most recent call last)
    <ipython-input-5-b1a80a7377c7> in <module>()
     37 Sframe = pd.concat(list,ignore_index=False)
     38 
---> 39 Sframe.to_csv(str(out_folder)+'\Combined_CSVs\Students_All '+str(st)+'.csv', sep=',')
     40 ##Concatenate fields and check for duplicates
     41     Sframe["TermSchoolStudent"]=Sframe["TermName"]+Sframe["SchoolName"]+Sframe["StudentID"].map(str)

C:\Users\mike\Anaconda3\lib\site-packages\pandas\core\frame.py in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, quoting, quotechar, line_terminator, chunksize, tupleize_cols, date_format, doublequote, escapechar, decimal, **kwds)
   1187                                      escapechar=escapechar,
   1188                                      decimal=decimal)
-> 1189         formatter.save()
   1190 
   1191         if path_or_buf is None:

C:\Users\mike\Anaconda3\lib\site-packages\pandas\core\format.py in save(self)
   1440         else:
   1441             f = com._get_handle(self.path_or_buf, self.mode,
-> 1442                                 encoding=self.encoding)
   1443             close = True
   1444 

C:\Users\mike\Anaconda3\lib\site-packages\pandas\core\common.py in _get_handle(path, mode, encoding, compression)
   2827                 f = open(path, mode, encoding=encoding)
   2828             else:
-> 2829                 f = open(path, mode, errors='replace')
   2830         else:
   2831             f = open(path, mode)

OSError: [Errno 22] Invalid argument:
C:\\Users\\mike\\Desktop\\S15 NWEA\\Combined_CSVs\\Students_All 2015-08-27 20:12:34.csv'

Thanks in advance, Michael

Dance Party
  • 3,459
  • 10
  • 42
  • 67

1 Answers1

0

The issue was with the part of the output CSV named 2015-08-27 20:12:34.csv. I could get away with dashes and colons in file names in Linux, but not in Windows.

Dance Party
  • 3,459
  • 10
  • 42
  • 67