I have the following SparseArray:
s = SparseArray[ {{1, 1} -> 1, {1, 2} -> 2, {1, 3} -> 3, {2, 1} -> 4, {2, 2} -> 5, {2, 3} -> 6, {3, 1} -> 7, {3, 2} -> 8, {3, 3} -> 9}]; I label it as follow:
TableForm[s, TableHeadings -> {{"A", "B", "C"}, {"E", "F", "G"}}] I can then export this to csv as,
Export["Desktop/test.csv", TableForm[s, TableHeadings -> {{"A", "B", "C"}, {"A", "B", "C"}}]] yet doing this does not preserve the heading labels. I wonder how can I keep them in the csv file?
TableHeadings -> ...as option toExport. $\endgroup$Export["test.csv", s, "TableHeadings" -> {{"A", "B", "C"}, {"E", "F", "G"}}], help page on CSV has similar example of using "TableHeadings". $\endgroup$"TableHeadings"option forExportis in the docs, but I for one was not aware of it. and had not even thought of looking. $\endgroup$