I am reading in some data from a CSV file that has a line which gives titles to each "column".

Here is an example:

Entry No,Val1,Val2,Val3,Val4

In reality this file has 20 or so values on each line, and therefore 20 column titles on the first line. I want to display this data in a table, so I first import the file and then display it like so:

dataSet1 = Take[Import["data_set_1.csv","CSV","HeaderLines"->1]] 

I want to be able to manipulate and plot my data later so I am pretty sure I have to remove the line containing the labels using the "Headerlines->1" option.

I would like the table to display the column titles that were on he first line of the CSV file. I know that I could specify them manually, but I think there should be someway to do this because I deleted them the set using "HeaderLines"

data= Import["http://pastebin.com/raw.php?i=7jJ4e2jW"];
titles = First@data; data = Rest@data;
TableForm[data, TableHeadings -> {None, titles}]
(*Displays the Table *)
(*Do Something with Data*)

enter image description here

  • $\begingroup$ thank you for your answer. I was actually asking about putting the titles on the table not on a plot. Also I tried to use your method of first and rest but It gave me errors. $\endgroup$ – Ajay Jul 25 '14 at 19:29
  • $\begingroup$ @Ajay This answer works perfectly with me. It also produces a table with the desired headings. $\endgroup$ – eldo Jul 25 '14 at 20:50
  • $\begingroup$ @eldo The answer has been edited since I tried to get that to run I for got that I needed to put None as the row labels in the table. $\endgroup$ – Ajay Jul 25 '14 at 21:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.