I am working on a project that requires me to independently verify the results of my Python code using another person's R code and a third person's Excel spreadsheet. (Yeesh.) Python was able to read the Excel file containing the source data, but the R script required a CSV and was not robust to parsing CSVs generated either by Excel or by pandas, failing silently both times.
I generated the CSV in Excel by using the Save As... function. In pandas, I used the following commands:
inFile = 'data-parsed-for-R.xlsx'
Data = pd.read_excel(inFile)
for site, subframe in Data.groupby('Site'):
outFile = site+'.csv'
outPath = os.path.join(workingDirectory, site, 'Data')
if not os.path.exists(outPath):
os.makedirs(outPath)
subframe.to_csv(path_or_buf=outPath+'\\'+outFile, na_rep='NA', header=['Foo', 'Bar', 'Baz', 'Qux', 'Quux', \
'Quuux','Quuuux'], index=False)
I have already solved the issue - see solution below; I'm submitting the question so that other people will hopefully be able to find it, and possibly comment on other interoperability issues they've discovered.